Jump to content

PHP Date Stamp


hackalive

Recommended Posts

<?php
$date_compare = new DateTime('2011-12-17T12:00:06+0000'); //start a date time object with the time to compare.
$current = new DateTime(); //and a date time object of the current time.
$difference = $date_compare->diff($current); //get the difference
//difference now holds an object with all of the information.
echo <<<EOF
<pre>
Years: {$difference->y}
Months: {$difference->m}
Days: {$difference->d}
Hours: {$difference->h}
Minutes: {$difference->i}
Seconds: {$difference->s}
</pre>
EOF;
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/253364-php-date-stamp/#findComment-1298861
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.