strtotime
(PHP 3 >= 3.0.12, PHP 4, PHP 5)
strtotime --
英文形式の日付をUNIXタイムスタンプに変換する
説明
int
strtotime ( string time [, int now] )
この関数は英文形式の日付を含む文字列が指定されることを期待してお
り、nowで与えられたその形式から
UNIXタイムスタンプへの変換を試みます。
引数が指定されない場合には現在日時が使用されます。
失敗すると-1を返します。
Because strtotime() behaves according to GNU
date syntax, have a look at the GNU manual page titled
Date Input Formats.
Described there is valid syntax for the time
parameter.
strtotime()はGNUの日付記法に準拠するように動作するので、
GNUマニュアルのDate Input Formats
をご覧ください。time引数の正しい記法が
掲載されています。
例 1. strtotime()の例
echo 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";
|
|
例 2. 失敗のチェック
$str = 'Not Good'; if (($timestamp = strtotime($str)) === -1) { echo "The string ($str) is bogus"; } else { echo "$str == ". date('l dS of F Y h:i:s A',$timestamp); }
|
|
注意:
タイムスタンプの有効な範囲は、通常、Fri, 13 Dec 1901 20:45:54
GMTからTue, 19 Jan 2038 03:14:07 GMTまでです。(これらは、32ビッ
ト符号付整数の最大及び最小に一致します。)