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

Hi,

don't use getDisplayValue()

always add hours, days etc to GMT value and set the value in GMT only

System takes care of showing the value to user as per his/her timezone in profile

var gdt = new GlideDateTime(inc.u_copy_updated);

gdt.addDaysUTC(1);

gr.setValue('u_field', gdt.getValue());

Regards
Ankur

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

@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

@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

@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

@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