-
Notifications
You must be signed in to change notification settings - Fork 2
Home
shumpei edited this page Sep 13, 2010
·
3 revisions
iso8601.js is easy-to-use JavaScript library for ISO-8601 datetime format.
Download source file and load using usual <script> tag.
<script type="javascript" src="iso8601.js"><script>
Functions are in “isodate” namespace.
Use “parse(text, type)”.
First argument “text” is iso-8601 style string.
Second argument “type” is HTML5-compatible type string(date, datetime, datetime-local, time, week).
Return value is built-in Date object.
isodate.parse("2009-09-09T11:02:36.123Z");
isodate.parse("2009-09-09T11:02:36.123Z", "datetime");
isodate.parse("2009-09-09", "date");
isodate.parse("11:02", "time");
isodate.parse("2009-W36", "week");
Use “format(date, type)”.
First argument “date” is built-in Date object.
Second argument “type” is format type.(see above)
isodate.format(new Date()); // -> "2009-09-09T11:02:36.123Z"
isodate.format(new Date(), "datetime"); // -> "2009-09-09T11:02:36.123Z"
isodate.format(new Date(), "date"); // -> "2009-09-09"
isodate.format(new Date(), "time"); // -> "11:02"
isodate.format(new Date(), "week"); // -> "2009-W36"