Get today's date in User's timezone - Workflow script

Ruchi19
Mega Contributor

In workflow script, I am using gs.now() to get today's date in wait for condition. If it is today's date then only tasks need to be created.
In the system timezone property, US / Eastern time is configured. I know gs.now() gets the current date using GMT.
Is there anyway to get the current date using specified time zone?

3 REPLIES 3

tony_fugere
Mega Guru

Not sure if this is the best way, but it seems to work.



var gdt = new GlideDateTime();
gdt.addSeconds(gdt.getTZOffset() / 1000);
var dateInMyTZ = gdt.getDate();


Thanks Tony. It helps.


If you want to find out the start of today, local time, in order to compare other times against it (e.g. for a query) you can use:



var today = gs.beginningOfToday();


the time string it gives is in GMT, but it represents your midnight. As an example, if your TZ was 'US/Pacific' then gs.beginningOfToday() would return "2011-11-21 08:00:00", if your TZ was 'Australia/South' it would return "2011-11-20 13:30:00"