タイムスタンプから時効への返還とかtime()
とかstrtotime()
とかの役割をすぐ忘れるので、備忘録。
date(タイムスタンプ→日時)
日付の文字列を返してくれる。
タイムスタンプを文字列の日時に直してくれる。
現在時刻取得
print date('Y/m/d');//20xx/x/x/
タイムスタンプを文字列に変換する
$timeStamp=time();
print date('Y/m/d h:i:s',$timeStamp);
strtotime(日時→タイムスタンプ)
英文形式の日付を Unix タイムスタンプに変換する。
日付をタイムスタンプ
例
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";
time
現在のUnixタイムスタンプを返す。
例
print time();