Parameters
date |
string | A serialized Campaign timestamp, e.g. a date attribute read from a query. |
Returns
| Date | A JavaScript Date. |
Examples
A date attribute read from a query comes back as a string, not a Date. Calling .getTime() or comparing it directly wonβt behave as expected: parse it first.
parseTimeStamp parses a Campaign timestamp string into a JavaScript Date, so you can compare it, do arithmetic on it, or store it as a workflow pointer. It is the read counterpart of π formatDate.
Read a date from a query
var xml = sqlSelect(
"delivery, @id:long, @lastModified:datetime",
"SELECT iDeliveryId, tsLastModified FROM NmsDelivery WHERE iState = 12"
);
var rows = DOMDocument.fromXMLString(xml.toXMLString()).root.getElements(); // E4X to DOM
var last = parseTimeStamp(rows[0].$lastModified); // string β Date
var ageMs = getCurrentDate().getTime() - last.getTime(); // now safe to computeTime zones:
parseTimeStampreads the value in the instance time zone. For UTC arithmetic, stock code wraps it inconvertToUTC(parseTimeStamp(...)).
See also
-
π formatDate- Format a date into a string using a Campaign date mask. Opposite of parseTimeStamp. -
π sqlSelect- Run a raw SQL SELECT on the native PostgreSQL tables and catalogs. Prefer queryDef for Adobe schemas.