Google

NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7">

strtotime

(PHP 3>= 3.0.12, PHP 4 )

strtotime --  英文形式の日付をUNIXタイムスタンプに変換する

説明

int strtotime ( string time, int [now])

この関数は英文形式の日付を含む文字列が指定されることを期待してお り、その形式からUNIXタイムスタンプへの変換を試みます。

例 1strtotime()の例

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ビッ ト符号付整数の最大及び最小に一致します。)