How to get current date time in user logged in time zone - client scripts

dharani2607
Tera Contributor

Hello,

I am using   var nowTime = new Date().getTime(); to get the current date time, but this is not returning in logged is user timezone.

Can anyone please let me know how to get urrent date time in user logged in  time zone in client scripts

Thanks

11 REPLIES 11

@dharani2607  

you cannot get that in client side; you will have to use Server Side only as I mentioned.

Please use GlideAjax in your client script. I hope you are aware on using GlideAjax syntax.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@dharani2607  

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@dharani2607  

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @dharani2607 Are you looking for client side or server side time check?

If client side then check link.

If server side then try below.

var nowTimeis=new GlideDateTime().getDisplayValue().toString();
var timeis=nowTimeis.split(' ')[1];
gs.print(timeis);

Hi,

 

Do we have some function to run on client side ? since I want to setup validation at client side script.