Created
November 16, 2012 21:33
-
-
Save smakhtin/4091108 to your computer and use it in GitHub Desktop.
Convert date from GMT to ISO 8601 format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ISODateString(d) { | |
| function pad(n){ | |
| return n<10 ? '0'+n : n | |
| } | |
| return d.getUTCFullYear()+'-' | |
| + pad(d.getUTCMonth()+1)+'-' | |
| + pad(d.getUTCDate())+'T' | |
| + pad(d.getUTCHours())+':' | |
| + pad(d.getUTCMinutes())+':' | |
| + pad(d.getUTCSeconds())+'Z' | |
| } | |
| var d = new Date(); | |
| print(ISODateString(d)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment