hackalive Posted December 17, 2011 Share Posted December 17, 2011 Hi guys, How can I compare 2011-12-17T12:00:06+0000 with a current date('c')? cheers in advance Link to comment https://forums.phpfreaks.com/topic/253364-php-date-stamp/ Share on other sites More sharing options...
hackalive Posted December 17, 2011 Author Share Posted December 17, 2011 I need to know the time diff in hours, mins and seconds (pref as three separate variables) Link to comment https://forums.phpfreaks.com/topic/253364-php-date-stamp/#findComment-1298775 Share on other sites More sharing options...
jcbones Posted December 17, 2011 Share Posted December 17, 2011 <?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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.