get previous month in php code example
Example 1: get current year php
<?php echo date("Y"); ?>
Example 2: get last month php
$currentMonth = date('M');
$lastMonth = Date("F", strtotime("first day of previous month");
$nextMonth = Date("F", strtotime("first day of next month");
Example 3: last day of previous month in php
$lastDay = date('t',strtotime('last month'));
print_r($lastDay);
Example 4: php date function get previous month
$tgl = '25 january 2012';
$prevmonth = date("M Y",mktime(0,0,0,date("m", strtotime($tgl))-1,1,date("Y", strtotime($tgl))));
echo $prevmonth;