Date Format in Script Output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 02:51 PM
Is there an easy way to script date fields into whatever format(s) I want?
/* The Created field prints as "2015-10-27 19:52:33" (but I want the time to show 7:52 PM). */
gs.print(current.sys_created_on);
/* Running the field through GlideDateTime gets me to the same output... */
var glideDateTime = new GlideDateTime(current.sys_created_on);
gs.print(glideDateTime.getValue()); // This also returns "2015-10-27 19:52:33"
/* ...so, NOW WHAT? */
In the past, I've done painful translations on my own to create a string by pulling out individual elements and putting them back in the order I want. I know I could reuse this work through something like a Script Include...but has all that already been done for me?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2015 04:01 PM
Hi Michael,
The below link should answer your question.
http://wiki.servicenow.com/index.php?title=Packages_Call_Replacement_Script_Objects#gsc.tab=0