dreamwest Posted December 22, 2008 Share Posted December 22, 2008 Is there a simple way to convert a time format like: Fri Dec 19, 2008 4:02 am Into how long ago this time was: 2 days, 15mins Link to comment https://forums.phpfreaks.com/topic/137980-is-there-a-better-way/ Share on other sites More sharing options...
Lamez Posted December 22, 2008 Share Posted December 22, 2008 Peak on over at: http://us.php.net/preg_replace Link to comment https://forums.phpfreaks.com/topic/137980-is-there-a-better-way/#findComment-721169 Share on other sites More sharing options...
Mark Baker Posted December 22, 2008 Share Posted December 22, 2008 <?php $inputTime = 'Fri Dec 19, 2008 4:02 am '; $timeThen = strtotime($inputTime); $timeNow = time(); $timeDiff = $timeNow - $timeThen; $seconds = ($timeDiff % 60); $timeDiff = floor($timeDiff / 60); $minutes = ($timeDiff % 60); $timeDiff = floor($timeDiff / 60); $hours = ($timeDiff % 24); $timeDiff = floor($timeDiff / 24); $days = $timeDiff; echo 'It has been '.$days.' Days, '.$hours.' hours and '.$minutes.' minutes since '.$inputTime; ?> But I really, really want to see how this can be done using only preg_replace() Link to comment https://forums.phpfreaks.com/topic/137980-is-there-a-better-way/#findComment-721193 Share on other sites More sharing options...
Lamez Posted December 22, 2008 Share Posted December 22, 2008 lmao! Oops I was reading the manual, and I did not read his question at all. I just assumed when I saw the example he gave. My Bad! Link to comment https://forums.phpfreaks.com/topic/137980-is-there-a-better-way/#findComment-721199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.