APIs, SDKs, and Services > XML-JSON API > Working with Schema Date and Time Types
  

Working with Schema Date and Time Types

Working with Schema Date and Time Types
In cases where the request and response contains xsd:dateTime type elements, the contents of these elements take the form YYYY-MM-DDTHH:MM:SS.sssZ (UTC time). However, the user interface in a browser deals with local time instead of UTC. You can use the following functions in the AE_UTIL object in the included ae-avc-utils.js.
Function
Description
AE_UTIL.xsdDateTimeToJsDateTime(xsdDateTimeStr)
Parses the ISO8601 xsd dateTime (YYYY-MM-DDTHH:MM:SS.sssZ) string and returns JavaScript Date object.

// task created on date. E.g: "2010-03-15T17:15:00.881Z" (12.15PM Eastern Time/GMT-5).
var createdOnXsdStr = AE_JSON_NODE_UTIL.getText(taskAbstracts[i].createdOn);
// convert to a JavaScript date object.
var createdDate = AE_UTIL.xsdDateTimeToJsDateTime(createdOnXsdStr);
AE_UTIL.xsdDateToJsDate(xsdDateStr)
Parses the xsd date (YYYY-MM-DD) string and returns JavaScript Date object.
AE_UTIL.xsdTimeToJsTime(xsdTimeStr)
Parses the XSD time (HH:MM:SS) string and returns JavaScript Date object. The returned date object contains the parsed time (but uses current date).
AE_UTIL.toXsdDateTime(date)
Converts a JavaScript Date object into a ISO8601 dateTime string (YYYY-MM-DDTHH:MM:SS.sssZ).
AE_UTIL.toXsdDateTimeFromDateAndTimeStr(date, time)
The date and time parameters are both JavaScript date objects. This function converts a date and time JavaScript Date objects into a ISO8601 dateTime string (YYYY-MM-DDTHH:MM:SS.sssZ).
AE_UTIL.toXsdDate(date)
Converts a JavaScript Date object into a ISO8601 date string (YYYY-MM-DD). Timezone information is not used.
AE_UTIL.toXsdTime(date)
Converts a JavaScript Date object into a ISO8601 time string (HH:MM:SS). Timezone information is not used.
When working with forms that use date and time types, first convert the raw JSON date/time information (ISO8601) to a JavaScript Date object before presenting it to the user (for example, using AE_UTIL.xsdDateTimeToJsDateTime(...) ). Conversely, the local date/time information from the user should be first converted to a ISO8601 (for exmple, using AE_UTIL.toXsdDateTime(...)) before sending it to Process Server.