I want to get today's date + one year. How do I achieve this with PHP's date functions?
To get the current year using PHP's date function, you can pass in the “Y” format character like so: //Getting the current year using //PHP's date function. $year = date("Y"); echo $year; The example above will print out the full 4-digit representation of the current year.
strtotime( date( 'd M ', $originaleDate ) . date( 'Y' ) ); This takes the day and month of the original time, adds the current year, and converts it to the new date. You can also add the amount of seconds you want to add to the original timestamp.
$year = date('Y') - 1; // Get current year and subtract 1 $start = mktime(0, 0, 0, 1, 1, $year); $end = mktime(0, 0, 0, 12, 31, $year);
echo date('Y', strtotime('+1 year'));
You can use strtotime
and date
$date = '2010-09-16'; echo date('Y-m-d', strtotime("+12 months $date")); // 2011-09-16
On a sidenote: DateTime questions like this have been answered over and over again, so you could have found how to add to a date easily by using the search function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With