DateTimeUtils - Global

DateTimeUtils class is a collection of date/time functions.

The DateTimeUtils class is provided via the Script Include DateTimeUtils.

The DateTimeUtils class can be used in any server-side script, and is available through GlideAjax.

DateTimeUtils - int8ToGlideDateTime(Number int64)

Converts Microsoft AD integer8 DateTime format into GlideDateTime format.

Integer8 is also known as Microsoft Filetime format. This method is commonly used when importing AD user's date fields, such as Expiration Date.

Table 1. Parameters
Name Type Description
int64 Number A 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
Table 2. Returns
Type Description
GlideDateTime A GlideDateTime object set to the Integer8 date and time.

//convert and set account expiration date from AD
//this is an example that could be used in an LDAP import transform map to import the LDAP account 
//expires attribute to a customer created u_account_expires GlideDateTime field
var dtUtil = new DateTimeUtils();
target.u_account_expires = dtUtil.int8ToGlideDateTime(source.u_accountexpires);

DateTimeUtils - msToGlideDateTime(Number milliseconds)

Converts milliseconds to a GlideDateTime object

Table 3. Parameters
Name Type Description
milliseconds Number The number of milliseconds
Table 4. Returns
Type Description
GlideDateTime A GlideDateTime object

//example script to call the method from a client
Replace MILLISECONDSVALUE with your variable
var ga = new GlideAjax('DateTimeUtils');
ga.addParam('sysparm_value', MILLISECONDSVALUE);
var newGDT = ga.getAnswer();