strtotime
strtotime ?? 英文形式の日付を Unix タイムスタンプに変換する
http://jp2.php.net/manual/ja/function.strtotime.php
int strtotime ( string $time [, int $now] )
けっこう柔軟に対応してくれるらしいのでいろいろ実験してみる
入力式 | 出力 | コメント |
---|---|---|
date('r',strtotime('1/2/3')) | Thu, 02 Jan 2003 00:00:00 +0900 | 月/日/年になる |
date('r',strtotime('1-2-3')) | Sat, 03 Feb 2001 00:00:00 +0900 | 年-月-日になる |
date('r',strtotime('2001/2/3')) | Sat, 03 Feb 2001 00:00:00 +0900 | 年/月/日になる |
date('r',strtotime('2-3-2001')) | Fri, 02 Mar 2001 00:00:00 +0900 | 日-月-年になる |
date('r',strtotime('1/2')) | Tue, 02 Jan 2007 00:00:00 +0900 | 今年の月/日になる |
date('r',strtotime('1-2')) | Thu, 01 Jan 1970 09:00:00 +0900 | お手上げ? |
date('r',strtotime('1:2')) | Fri, 07 Sep 2007 01:02:00 +0900 | 今日の時:分になる |
date('r',strtotime('1-2-3 4:5:6')) | Sat, 03 Feb 2001 04:05:06 +0900 | 全部指定 |
strtotime()はGNUの日付記法に準拠するように動作する、というわけで詳細はこちら
http://www.gnu.org/software/tar/manual/html_node/tar_109.html