php時間変換
649 ワード
function string date(string $format[,int $timestamp])
現在時刻の取得
$currentdate=date('Y-m-d H:i:s');
echo $currentdate;
結果:2014-02-20 11:46:42
指定した時間を時間文字列に変換することもできます
$datetime=date('Y-m-d H:i:s',1390189602);
echo $datetime;
結果:2014-01-20 11:42:33
int strtotime ( string $time [, int $now = time() ] )
時間をミリ秒に変更:
$intdate=strtotime('now');
echo $intdate;
結果:1392868352
$intlastmonth=strtotime('last month');
echo $intlastmonth;
結果:1390189952