The ISO8601DateUtils.jsm
JavaScript code module provides methods that make it easy to convert JavaScript Date
objects into ISO 8601 format date strings and back.
To use this, you first need to import the code module into your JavaScript scope:
Components.utils.import("resource://gre/modules/ISO8601DateUtils.jsm");
Once you've imported the module, you can then use the ISO8601DateUtils
object it exports.
To convert a date string into a Date
object, simply use:
dateObj = ISO8601DateUtils.parse(dateString);
To convert a Date
object into a date string:
dateString = ISO8601DateUtils.create(dateObj);
String create(aDate); |
Date parse(aDateString); |
Creates an ISO 8601 format date string, e.g. "2010-05-15T13:45:00Z", from a JavaScript Date
object.
String create( aDate );
aDate
Date
object to translate into an ISO 8601 format string.An ISO 8601 format date string.
Converts an ISO 8601 format date string into a JavaScript Date
object.
Date parse( aDateString );
A JavaScript Date
object corresponding to the specified date string.
Date.parse
for reading ISO8601 dates Date.toISOString
for putting out ISO8601 dates