Comments on: Client Side Dates in ServiceNow https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/ ServiceNow Consulting Scripting Administration Development Tue, 12 Mar 2024 21:23:59 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: John Boyland https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/#comment-9758 Fri, 23 Jun 2017 03:39:32 +0000 https://servicenowguru.wpengine.com/?p=12051#comment-9758 Looks like a basic implementation of moment.js is available in service portal, however this only works from service portal and not the backend.

By default the format of the date component is incorrecnt and will need to be converted to uppercase to work with moment.js. You could do something like this which should work.

var dateFormat = g_user_date_format.toUpperCase();
// get the full date time format
var dateTimeFormat =g_user_date_time_format;
// construct correct date time format where we strip the date and use the upcase version
var newDateTimeFormat = dateFormat + dateTimeFormat.substring(dateFormat.length);

//create date object using moments and correct date time format
var dateObj = moment(g_form.getValue(‘the_date_field’), newDateTimeFormat);

]]>
By: James Farrer https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/#comment-9757 Tue, 30 May 2017 16:37:14 +0000 https://servicenowguru.wpengine.com/?p=12051#comment-9757 In reply to Kamal Garg.

Unfortunately, I haven’t found a great solution for Service Portal yet. I think it’d be a great enhancement request to ServiceNow to add support back in. If I can find something I’ll post it here.

]]>
By: Kamal Garg https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/#comment-9756 Wed, 24 May 2017 11:42:13 +0000 https://servicenowguru.wpengine.com/?p=12051#comment-9756 But getDateFromFormat doesnt work on service portal . is there any alternativ for it to run on service portal

]]>
By: Richard Selby https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/#comment-9755 Thu, 23 Feb 2017 11:49:57 +0000 https://servicenowguru.wpengine.com/?p=12051#comment-9755 Thanks, James. Very handy.

]]>
By: Jawaharlalnehru Vaiyapuri https://servicenowguru.com/client-scripts-scripting/client-side-dates-in-servicenow/#comment-9754 Wed, 22 Feb 2017 19:09:25 +0000 https://servicenowguru.wpengine.com/?p=12051#comment-9754 This is really a cool cheat sheet kind of information to be handy always… when ever you are having users in multiple time zones and multiple time formats…

]]>