getDisplayValue() of a date/time field is giving wrong values

Debasis Pati
Tera Guru

if the date is below

 then getDisplayValue is giving  2021-07-03 13:00:00

 

 

@Ankur Bawiskar @Harshvardhan 

Please help

Regards,

Debasis

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Debasis Pati 

getDisplayValue() will always print the value as per user's timezone or the timezone present in the user settings.

Can you explain where you are using that and what is not working?

Regards
Ankur

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

View solution in original post

14 REPLIES 14

@Debasis Pati 

Hope you are doing good.

Did my reply answer your question?

Would you mind marking the best matching answer as correct and helpful, to close this thread?

Regards
Ankur

 

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

Anil Lande
Kilo Patron

Hi,

Please check below links:

getDisplayValue on date fields get the date Value based on logged In users time zone.

 

https://developer.servicenow.com/dev.do#!/reference/api/paris/server/no-namespace/c_APIRef#r_ScopedG...

https://community.servicenow.com/community?id=community_question&sys_id=97564cd4db10dcdcd58ea345ca96...

 

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Ankur Bawiskar
Tera Patron
Tera Patron

@Debasis Pati 

getDisplayValue() will always print the value as per user's timezone or the timezone present in the user settings.

Can you explain where you are using that and what is not working?

Regards
Ankur

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

Anurag Tripathi
Mega Patron
Mega Patron

Not read the whole thread, so apologies if this is already covered.

getDisplayValue  on date field gives the dates in the logged in user's time zone and format. Maybe that is why you are seeing the difference.

-Anurag

shibinmonjoseph
Tera Expert

Please try "getDisplayValueInternal()"

 

getDisplayValueInternal() gets the display value in the internal format.
(Returns the date and time values for the GlideDateTime object in the current user's time zone and the internal date)