Convert a Date object to an ISO 8601 formatted string


/ Published in: JavaScript
Save to your folder(s)

Javascript which converts a Date object into an ISO 8601 formatted string - 'YYYY-MM-DDTHH:mm:ss.sssZ' - with a fallback for when the function 'toISOString' doesn't exist (e.g. IE 8 or less).

Usage:
var now = new Date;
console.log(now.toISOString());

Validates clean in JSLint (Edition 2012-12-31).

URL: http://jsfiddle.net/davidwaterston/LMxwz/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.