1

I'm trying to convert this "2012-03-27 16:01:48 CEST" into "1 hour and 22 minutes since". Preferably automatic time-zone management.

I can not change how the time is set. It will always be "2012-03-27 16:01:48 CEST" or something similar. Any ideas? I'm open for anything!

Mats Bakken
  • 155
  • 1
  • 14
  • 1
    This answer might help you. [How to format time since xxx e.g. “4 minutes ago” similar to Stack Exchange sites][1] [1]: http://stackoverflow.com/questions/3177836/how-to-format-time-since-xxx-e-g-4-minutes-ago-similar-to-stack-exchange-site – Epuri Mar 27 '12 at 14:51

3 Answers3

2

I love DateTime!

$a = new DateTime('2012-03-27 16:01:48 CEST');
$b = new DateTime();

$diff = $b->diff($a);

echo $diff->h,' hours and ',$diff->i,' minutes';
dan-lee
  • 14,365
  • 5
  • 52
  • 77
0

Take a look at: http://www.datejs.com/ It's a handy library for formatting and calculating dates.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
0

Check php gmdate() function

wormhit
  • 3,687
  • 37
  • 46