Last active
October 13, 2016 04:22
-
-
Save webbingstudio/81bdc33a8f87798b032d436d4977326f to your computer and use it in GitHub Desktop.
iso8601をDateオブジェクトに変換する ref: http://qiita.com/webbingstudio@github/items/74ff85bdac03f1a9aec7
This file contains 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
var iso8601Date = function(iso) { | |
var parse = iso.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\+\d{2}:\d{2}/); | |
return new Date( Number(parse[1]), Number(parse[2]), Number(parse[3]), Number(parse[4]), Number(parse[5]), Number(parse[6]) ); | |
}; | |
... | |
var pubdate = iso8601Date( '2016-10-12T17:47:15+09:00' ); | |
console.log(pubdate[1]); //2016 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment