How to convert GMT date to EST

jesusemelendezm
Mega Guru

When importing expirydate from LDAP to sys_user table - I am obtaining an incorrect date. If user expiry date in Active directory is 31/12/2014 the date being displayed on the user form on ServiceNow is 01/01/2015 I was told that It is being imported on GMT and I need to convert it to EST. Can I do it directly on the date field?


Capture.JPG

1 ACCEPTED SOLUTION

It will only affect that one particular variable and field.   Your script is not quite right though as you need to modify the timezone for your gDate variable.   You need to put:



//converting GMT to Canada/Eastern


var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");


gDate.setTZ(tz);



...right after you initialize the variable and before you assign the date to it.     You should end up with:



var gDate = Packages.com.glide.glideobject.GlideDateTime();


//converting GMT to Canada/Eastern


var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Eastern");


gDate.setTZ(tz);


gDate.setValue(msDate);


View solution in original post

17 REPLIES 17

no, It was not solved. Still getting + day of the current LDAP date. I have escalated it this issue with our consultants. Thanks for the help


OK, good, thanks for the update.


Were you ever able to find a solution for this?   I am having a similar problem.