In this tutorial you will learn how to PHP date get next month in a PHP web application.
PHP date get next month
In this tutorial you will learn how to PHP date get next month in a PHP web application. In this tutorial $todayDate variable that store current date and date format 'Y-m-d' . The getNextMonth($date) function that return next month name. The code of "php-date-get-next-month.php" given below :
<?php function getNextMonth($date)//date format 'Y-m-d' { $date_tmp = explode("-",$date); $next_date =mktime(0, 0, 0, $date_tmp[1]+1, $date_tmp[2], $date_tmp[0]); return date('M',$next_date)."(".date('m',$next_date).")"; } //PHP Example get next month $todayDate = date("Y-m-d");// current date echo "Today: ".$todayDate."<br>"; echo " Next month : ".getNextMonth($todayDate); ?>
Output :
When run "php-date-get-next-month.php" display output as :
[ 0 ] Comments