Upload
masunaga-ray
View
9.932
Download
0
Embed Size (px)
Citation preview
増永 玲 (@msng)
・増永 玲(マスナガ | msng)といいます。
・ウェブのサービスを作って運営するなどしています。
・ / msng
・『頭ん中』というブログを書いています。 http://www.msng.info/
好きな PHP の関数は?
もちろん 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";?>
strtotime はできる子
echo strtotime("20121104");//1351954800
echo strtotime("121104");//1351998664 = 2012/11/04 12:11:04
echo strtotime("2012/11/04");//1351954800
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
そこで 超strtotime
{
"year": 1974,
"month": 4,
"day": 13,
"mmdd": "0413",
"timestamp": 135010800
}
http://strtoti.me/1974.4.13
もちろん 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
もちろん漢数字対応http://strtoti.me/二千十二年十一月四日
{
"year": 2012,
"month": 11,
"day": 4,
"mmdd": "1104",
"timestamp": 1351954800
}
もちろん元号対応http://strtoti.me/平成元年一月八日
{
"gen": "平成",
"gen_year": 1, "show_year": "平成元年", "year": 1989,
"month": 1,
"day": 8,
"mmdd": "0108",
"timestamp": 600188400
}
もちろん元号バリデーションつき
{
"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日
もちろん元号バリデーションつき
{
"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
もちろん閏年バリデーションつき
{
"show_year": "2013年",
"year": 2013、
"month": 2,
"day": 29,
"mmdd": "0229",
"notice": "2013年の2月は28日までです。", "timestamp": 1362063600
}
http://strtoti.me/2013-02-29
Q: 日付だけ? 時刻は?
日付とかよりラーメンだろ。(帰ったら対応します)
A: PHPMatsuri in 福岡ですよ
Q: ソースコードは?
コードが の中なのでちょっと待ってね。
A: 公開します。
闇