Scoped application - How to get current date/time of a specific timezone.

divyasurada
Tera Contributor

Hi,

I am trying to get the time difference between the current time/Date and end_time (time/date) based on Time zone provided by the user in SCOPED application.

To achieve this I need to first get the current time/date in the time zone provided by the user. Please help me with this.

Thanks in Advance.

 

1 ACCEPTED SOLUTION

Anirban Roy
Mega Guru

Hi,

You would need to add a timezone offset to get the date time in a specific timezone.

This can be achieved in global scope using package calls or using setTZ method for a logged in users session object.

However, there is no api accessible in scoped apps. You may look at the moment.js opensource library.

//below piece of code will give you the timezone offset w.r.t UTC...

var tZSetOnVarOffSet = moment.tz(moment.utc(), tZSetOnVar).utcOffset();

//-- you can add the timezone offset to your current date time to fetch the date time in another timezone

I am adding the link of your previous question as well, as the solution for both are similar. You can follow the detailed script in the below question answer -

https://community.servicenow.com/community?id=community_question&sys_id=871e4912dbfd90105d782183ca96...

 

Regards,

Anirban

View solution in original post

6 REPLIES 6

Taha6
Tera Expert

There is an OOB script include for that rmConvertTimeZone 

 

find_real_file.png

Deepak92
Tera Contributor

Hello,

Do any one have any solution on this ??