Skip to content

Instantly share code, notes, and snippets.

@allensarkisyan
Created September 29, 2012 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allensarkisyan/3805208 to your computer and use it in GitHub Desktop.
Save allensarkisyan/3805208 to your computer and use it in GitHub Desktop.
ISO 8601 timestamp for facebook open graph implementations, omitted seconds
// ISO 8601 Date Prototype - Usage example: (new Date).ISO8601();
Date.prototype.ISO8601 = function() {
function wrap(n) { return (n < 10 ? '0' + n : n) }
var dt = this;
return dt.getUTCFullYear() + '-' + wrap(dt.getUTCMonth() + 1) + '-' + wrap(dt.getUTCDate()) + 'T' + wrap(dt.getUTCHours()) + ':' + wrap(dt.getUTCMinutes());
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment