17
増永 玲 (@msng)

超strtotime()

Embed Size (px)

Citation preview

Page 1: 超strtotime()

増永 玲 (@msng)

Page 2: 超strtotime()

・増永 玲(マスナガ | msng)といいます。

・ウェブのサービスを作って運営するなどしています。

・ / msng

・『頭ん中』というブログを書いています。 http://www.msng.info/

Page 3: 超strtotime()

好きな PHP の関数は?

もちろん strtotime() ですよね。

Page 4: 超strtotime()

strtotime はできる子<?phpecho strtotime("now"), "\n";echo strtotime("10 September 2000"), "\n";echo strtotime("+1 day"), "\n";echo strtotime("+1 week"), "\n";echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";echo strtotime("next Thursday"), "\n";echo strtotime("last Monday"), "\n";?>

Page 5: 超strtotime()

strtotime はできる子

echo strtotime("20121104");//1351954800

echo strtotime("121104");//1351998664 = 2012/11/04 12:11:04

echo strtotime("2012/11/04");//1351954800

Page 6: 超strtotime()

strtotime が苦手なこと

echo strtotime("2012.11.04");//false

echo strtotime("2012年11月4日");//false

echo strtotime("H24-11-04");//1730649600 = 2024-11-04 01:00:00

Page 7: 超strtotime()

そこで 超strtotime

http://strtoti.me/

Page 8: 超strtotime()

そこで 超strtotime

{

"year": 1974,

"month": 4,

"day": 13,

"mmdd": "0413",

"timestamp": 135010800

}

http://strtoti.me/1974.4.13

Page 9: 超strtotime()

もちろん JSONP 対応

birthday({"gen":"\u662d\u548c","year":1974,"month":4,"day":13,"mmdd":"0413","gen_year":49,"show_year":"\u662d\u548c49\u5e74","timestamp":135010800})

http://strtoti.me/S49.04.13?callback=birthday

Page 10: 超strtotime()

もちろん漢数字対応http://strtoti.me/二千十二年十一月四日

{

"year": 2012,

"month": 11,

"day": 4,

"mmdd": "1104",

"timestamp": 1351954800

}

Page 11: 超strtotime()

もちろん元号対応http://strtoti.me/平成元年一月八日

{

"gen": "平成",

"gen_year": 1, "show_year": "平成元年", "year": 1989,

"month": 1,

"day": 8,

"mmdd": "0108",

"timestamp": 600188400

}

Page 12: 超strtotime()

もちろん元号バリデーションつき

{

"gen": "大正",

"gen_year": 20,

"show_year": "大正20年",

"year": 1931,

"month": 5,

"day": 5,

"mmdd": "0505",

"notice": "大正は15年までです。", "timestamp": -1220086800

}

http://strtoti.me/大正20年5月5日

Page 13: 超strtotime()

もちろん元号バリデーションつき

{

"gen": "昭和",

"gen_year": 64,

"show_year": "昭和64年",

"year": 1989,

"month": 1,

"day": 31,

"mmdd": "0131",

"notice": "昭和64年は1月7日までです。", "timestamp": 602175600

}

http://strtoti.me/S64.1.31

Page 14: 超strtotime()

もちろん閏年バリデーションつき

{

"show_year": "2013年",

"year": 2013、

"month": 2,

"day": 29,

"mmdd": "0229",

"notice": "2013年の2月は28日までです。", "timestamp": 1362063600

}

http://strtoti.me/2013-02-29

Page 15: 超strtotime()

Q: 日付だけ? 時刻は?

日付とかよりラーメンだろ。(帰ったら対応します)

A: PHPMatsuri in 福岡ですよ

Page 16: 超strtotime()

Q: ソースコードは?

コードが の中なのでちょっと待ってね。

A: 公開します。

Page 17: 超strtotime()

http://strtoti.me/