日付オブジェクトとして今日の日付をどのように取得しますか?PHPの日付オブジェクトとして現在の日付/時刻を取得する方法
開始日と今日の差を計算しようとしています。
$today = getdate();
$start = date_create('06/20/2012');
$diff = date_diff($start, $today);
echo($today . '<br/>' . $start . '<br/>' . $diff);
出力:
Array ([seconds] => 8 [minutes] => 1 [hours] => 16 [mday] => 11 [wday] => 1 [mon] => 6 [year] => 2012 [yday] => 162 [weekday] => Monday [month] => June [0] => 1339455668)
DateTime Object ([date] => 2012-06-20 00:00:00 [timezone_type] => 3 [timezone] => America/Los_Angeles)
明示的な '$ today = new DateTime(" now ");は、引数がデフォルトで" now "になっていても、より明白だと思います。 – jedwards
コード* $ today = new DateTime( 'now'); *は実際に何らかのエラーを投げています。 (500内部サーバーエラー) – McGarnagle
@dbasemanより具体的になることができますか?実行中のPHPのバージョンは? http://codepad.org/5lYyo8MC –