Jump to content

Is there a better way


dreamwest

Recommended Posts

<?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()

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.