Notifications

943 views

How to properly initialize GlideDateTime


Description


This document describes how you can initialize a GlideDateTime variable with a pre-defined value

Procedure


The GlideDateTime constructor’s parameters must be formatted in the internal format (yyyy-MM-dd HH:mm:ss) and in the UTC time zone.

Note: A common mistake is to pass the constructor times in the user format and the local time zone.

 

The setValue() and getValue() methods require parameters in the UTC time zone and internal format. Other formats may return invalid results.

The toString() method returns the same string as the getValue() method.

The setDisplayValue() and getDisplayValue() methods require parameters in the local time zone (user/system) and local format (user/system). Other formats may return invalid results.

//Example: If user’s date time format is MM.dd.yyyy HH:mm:ss

// Do this

var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime();
gdt.setDisplayValue(input);

// Not this

var input = “08.05.2015 16:21:47”;
var gdt = new GlideDateTime(input);

Applicable Versions


Istanbul, Jakarta, Kingston 

Article Information

Last Updated:2018-05-18 01:03:42
Published:2018-05-18