change datetime format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 10:36 AM
Lots of posts our there to bring datetime format back to system format, all fine a good, but how can I go the other way,
I need to convert the format from system default format to a custom format
from: yyyy-mm-dd hh:mm:ss
to: E MMM dd yyyy HH:mm
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 10:42 AM
Use below blog
https://community.servicenow.com/community?id=community_blog&sys_id=bc0e6a2ddbd0dbc01dcaf3231f961931
Regards,
sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 10:44 AM
Hi Wade,
I would use below.
var newDate = 'Monday, June 10, 2020 11:00 AM';
var gdt = new GlideDateTime();
gdt.setDisplayValue(newDate,'E, MMMM dd, yyyy HH:mm');
var dateTimeForField = gdt.getDisplayValue();
gs.print(dateTimeForField);
Also, look link that I always prefer for a check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 02:21 PM
This is all good, but how would change input 2020-06-08 11:51
to Mon, June 8, 2020 11:51