Hi guys, I guess that question was asked a hundred...
# suitescript
l
Hi guys, I guess that question was asked a hundred times but what is the default timezone of a Map/Reduce script or a Scheduled Script ? From answer 89624, I guess it is the default Company Preference Time (Setup > Company > Company Information) but I am not sure. When I do this
log.audit('Time', new Date().toString())
, the time doesn't match my timezone. That's ok, I can convert it. But it raises another question : what is the timezone used to save the records ? If I create a saved search (in a script, with
search.create()
), should I convert my time to the "default Company Preference Time" ?
From what I can understand, on the "database", the datetime is stored in a specific format (probably pacific timezone). So when, in a M/R script, I create a new date (pacific timezone then), the saved search uses the same timezone so that's fine. On a RestLet, the timezone is the timezone of the user (defined by his own preferences). Same for a UserEvent Script.
b
timezone of Dates created in serverside scripts is pacific
timezone used to save records is timezone of the current user
if that user is the system user like in scheduled or map/reduce scripts, the timezone is the timezone in company information
use N/format for your string conversion needs
otherwise N/record methods can use a Date object if you can correctly create your Date
l
Ok. So it means that if I want to search for "all the vendor bills created today before 1:00 PM" (for example), as parameter to my saved search I need to pass a date formated to the timezone of the company information ?
b
yes, although 1:00 pm today is ambiguous for Date purposes
many different Dates represent 1:00 pm in different timezones
l
Indeed. It was for the example. My real case is "all the transaction created within the last half hour and the last hour".
b
thats actually a lot easier to do
you can use a relative date search filter
or you can create a new Date() and then subtract minutes from it