Need help with BR to convert timezone to UTC

eliana_wise
Tera Contributor

Hi,

I have 4 fields on my change form that needs to be shown UTC time zone; I have gone through majority of the community threads, but couldn't find the solid answer for my request. Please advise.

1 ACCEPTED SOLUTION

Baala T
Mega Guru

Hi Eliana,



If you define a column with the type of "Date", the system will stores value only in UTC. While displaying the value will get converted from UTC to User timezone. If you want to display the value in UTC irrespective of User Timezone, define the column with the type of "String" and store the value in UTC. The String type values will not get converted. It will get displayed as it is.



Use this command to get the current time in UTC


gs.nowNoTZ()


View solution in original post

7 REPLIES 7

Shishir Srivast
Mega Sage

I believe you should be able to do with getValue()



GlideDateTime - getValue()


Returns the date and time value stored by the GlideDateTime object in the internal format, yyyy-MM-dd HH:mm:ss, and the system time zone, UTC by default.



var gdt = new GlideDateTime();


gs.print(gdt.getValue());


Output: 2018-02-14 03:15:44



GlideDateTime - Global



Please share your code, how are you trying to do for more clarity.


or you can check: JavaScript toUTCString() Method , but this will give date which will be in below format. like


Fri Mar 25 2015 09:56:24


Hi Shishir,



Thanks for your reply, I went through the article; I will try to see if I can apply the mentioned script in my BR.



Regards


Kunal Jha
Giga Expert

Eliana - I am not pretty sure what's you business case but you need to set the display value of that 4 field.



to convert use


var d = new Date();


      var n = d.toUTCString();


n is your value.