how to get current date in netsuite
Hi All,
Most of the time , there are scenario where we want to have today's date as per system.
For Example if we want to add custom search between today and some other date then we need to find todays date as per system.
We can also add parameter in nlapiDateToString and modify date as per our need.
Best way to do this using below code:
First find Todays date using javascript api:
var todaydate = new Date();
Now in Script 1.0 use nlapiDateToString method to get date as per Netsuite's setting.
var today = nlapiDateToString(todaydate);
Note: new Date() will give server's date/time if we use on server side and user's date/time if we use in client script.
You can add also find any other date by adding days or months and years using date apis.
Want to add Days? Click Here
Feel free to comment if you have any doubt.
Thanks
Most of the time , there are scenario where we want to have today's date as per system.
For Example if we want to add custom search between today and some other date then we need to find todays date as per system.
We can also add parameter in nlapiDateToString and modify date as per our need.
Best way to do this using below code:
First find Todays date using javascript api:
var todaydate = new Date();
Now in Script 1.0 use nlapiDateToString method to get date as per Netsuite's setting.
var today = nlapiDateToString(todaydate);
Note: new Date() will give server's date/time if we use on server side and user's date/time if we use in client script.
You can add also find any other date by adding days or months and years using date apis.
Want to add Days? Click Here
Feel free to comment if you have any doubt.
Thanks
how to get same in suitescript 2.0?
ReplyDeleteuse format.format(options)
Deletevar mydate= "09/28/2019";
format.format({value:mydate, type: format.Type.DATE})
or try
var mydate= "09/28/2019";
var parsedDate= format.parse({
value: mydate,
type: format.Type.DATE
});