Wednesday, March 27, 2019

SuiteScript > Compare current time with specified time of a day

A small and simple SuiteScript/JavaScript code that will compare the current time with specified time of the day.

var cudate=new Date();   //gets the current date and time
var date=nlapiDateToString(cudate); //gets the current date excluding the time
comparetime="12:00:00" //specified time of the day
var compareDateTime = new Date(date+' '+comparetime); //concatenating current date and the comparison time
if(cudate >compareDateTime)  // comparing current date/time with the defined date and time=12:00pm
{
//do this
}

No comments:

Post a Comment