How to convert Timestamp into days hours mins ago ?
E.g I have a Timestamp : 2014-02-27 09:37:20
How to convert this timestamp into 4 day, 2 hours ,20mins ago ?
How to convert Timestamp into days hours mins ago ?
E.g I have a Timestamp : 2014-02-27 09:37:20
How to convert this timestamp into 4 day, 2 hours ,20mins ago ?
You should be better of with the DateTime::createFromFormat
<?php
$dt='2014-02-27 09:37:20';
$date = DateTime::createFromFormat('Y-m-d H:i:s', $dt);
$currdt=new DateTime();
$currdt->diff($date);
echo $currdt->format('d')." days ".$currdt->format('H')." hours ".$currdt->format('i')." mins ago";
OUTPUT :
04 days 05 hours 31 mins ago
Is this something you're looking for?
// built with php5
// set system default time zone
$timeZone = 'UTC';
date_default_timezone_set($timeZone);
// find the difference
$interval = date_diff(date_create('2014-02-27 09:37:20'), date_create());
$out = $interval->format("Days:%d,Hours:%H,Minutes:%i");
print_r($out);
For the list of available time zone string you may find here http://www.date-default-timezone-set.com/