Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

ISO8601DateUtils.jsm

Nos bénévoles n'ont pas encore traduit cet article en Français. Aidez-nous à réaliser cette tâche !

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.

Using the ISO 8601 date utilities

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);

Method overview

String create(aDate);
Date parse(aDateString);

Methods

create

Creates an ISO 8601 format date string, e.g. "2010-05-15T13:45:00Z", from a JavaScript Date object.

String create(
  aDate
);
Parameters
aDate
A JavaScript Date object to translate into an ISO 8601 format string.
Return value

An ISO 8601 format date string.

parse

Converts an ISO 8601 format date string into a JavaScript Date object.

Date parse(
  aDateString
); 
Parameters
aDateString
An ISO 8601 format date string.
Return value

A JavaScript Date object corresponding to the specified date string.

See also

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : teoli, Yansky0, fscholz, Torisugari, trevorh, MKaply, BenB, Sheppy
 Dernière mise à jour par : teoli,