How am I able to get the value of the previous year using PHP. Are there any predefined functions for it?
If you want to display the entire date exactly 1 year ago, including the month and year:
<?php echo date("M d Y", strtotime("-1 year")); ?>
This thread needs an update.
Nowadays you would use the PHP date-time object and do something like this:
$lastYear = new DateTime();
$lastYear->sub(new DateInterval('P1Y'));
echo $lastYear->format('Y');
you can give a value of the input tag as :
<?php echo date("Y-m-d",strtotime("-1 year"));?>
try
echo date("Y",strtotime("-1 year"));
Try This
date('Y', strtotime('last year'));
$year = date("Y");
$previousyear = $year -1;
http://php.net/manual/de/function.date.php