如何显示下个月?
$tz = new DateTimeZone('Pacific/Nauru');
$date = new DateTime('now', $tz);
$monthFull = $date->format('F');
答案 0 :(得分:1)
只需将下面的一行添加到您现有的代码中,如图所示。
$date->add(new DateInterval('P1M'));
<?php
$tz = new DateTimeZone('Pacific/Nauru');
$date = new DateTime('now', $tz);
$date->add(new DateInterval('P1M')); //<------- Added here
echo $monthFull = $date->format('F'); //"prints" March
答案 1 :(得分:0)
使用它:
$tz = new DateTimeZone('Pacific/Nauru');
$date = new DateTime('now', $tz);
$date->modify("+1 month");
$monthFull = $date->format('F');
答案 2 :(得分:0)
试试这个,使用modify()
$date = new DateTime('now', $tz);
$date->modify( 'next month' );
echo $date->format( 'F' ), "\n";
答案 3 :(得分:0)
$timeStamp = strtotime('next month');