i want to have a date 6 years from now?
how do i do that?
<?php
$timestamp = strtotime('+6 years');
echo date('Y-m-d H:i:s', $timestamp);
?>
date_default_timezone_set('America/Los_Angeles'); //required if not set
$date = new DateTime('1/1/1981');
$date->modify('+60 year');
echo $date->format('Y-m-d');
Above is not affected by unix time stamp date range (before 1970 and after 2038).
Also you can directly compare dates with Comparison operators directly, no need convert them to Time stamp.
Requires PHP 5.3
strtotime('+6 years');
you can pass that timestamp into something like strftime(); strtotime
Still laughing about ChaosPandion's comment :)
echo strtotime ("+6 years");
should do the trick.
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