下个月格式('F')

时间:2014-02-12 04:00:41

标签: php html

如何显示下个月?

$tz =  new DateTimeZone('Pacific/Nauru');
$date = new DateTime('now', $tz);
$monthFull = $date->format('F');

4 个答案:

答案 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

Demo

答案 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');