Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get current date..now()?

aarav
Kilo Contributor

Hi friends.

I want to capture the current date to one of my field.

We can capture the time from nowDateTime() function.

But i want to capture directly   In 28-Nov-2016 format.

can we use           function   : now()

But it says 'Gets the current date using GMT date time.'   .

My question is will it capture current date?     as its mentioned GMT...will it capture different date.....

if yes then in what format it will capture..

I am not able to produce/create scenario here to test...

Please advice

Thank you very much in advance.

regards

Aarav

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi Aarav,



You can use .getDisplayValue(); for capturing current date of your time zone.



For instance, to get current date of opened field you can use



var abc=current.opened.getDisplayValue();


Also, you can use setDisplayValue to set the time to now:



current.opened.setDisplayValue(gs.nowDateTime());


Hi Jaspal,

 

In Rest Api am trying to query using sys_created_onONgs.nowDateTime()

 

This returns in GMT.

 

Is it possible to get result user's timezone ?

hi you can try gs.getSession().getTimeZoneName();

 

 

also read How to I get the user's current Timezone settings via api calls / scripting?