The CreatorCon Call for Content is officially open! Get started here.

User Date Format and .setValue (date / time) inconsistencies

CarlStoepker
Giga Contributor

This script takes start_date from a record, adds 14 days and puts the result into end_date of the same record:

    var inpDate = new GlideDateTime();

    inpDate.setDisplayValue(chg.start_date);

    inpDate.addDays (14);

    chg.end_date = inpDate;

    chg.update();

The funny thing is that I get the following in the form:

Start Date (start_date):                       2014-02-18 17:00:29                                          

End Date (end_date):                                       2014-03-04 22:00:29

The difference between the two is 14 days and 5 hours!!!!

Where is the 5 hours coming from and how can I make this work correctly?

Het bericht is bewerkt door: Carl Stoepker Updated the title to better reflect the content

5 REPLIES 5

johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: GlideDateTime



Visit http://docs.servicenow.com for the latest product documentation