Page 1 of 1
Number of seconds to minutes and seconds
Posted: Thu Oct 26, 2006 6:09 am
by ianripping
Hi,
I have a script that is returning a time in a number of seconds eg 218 seconds.
Is there a function in PHP,(im sure there will be) that will change say 69 seconds, to 01:09?
Thanks in advance
Posted: Thu Oct 26, 2006 6:38 am
by volka
Posted: Thu Oct 26, 2006 6:59 am
by ianripping
This print 01:03:38 - why is the hour 01? it should be 00
Posted: Thu Oct 26, 2006 7:39 am
by volka
oh sorry, date() takes the server's timezone into account.
00:00:00 1970 GMT was 01:00:00 1970 in your timezone.
Code: Select all
<?php echo gmdate('H:i:s', 218); ?>
prints
00:03:38
Posted: Thu Oct 26, 2006 7:57 am
by feyd
Alternately, you could use printf's (that's the username, not the function) snippet found in Code Snippets.
Posted: Thu Oct 26, 2006 8:09 am
by ianripping
volka wrote:oh sorry, date() takes the server's timezone into account.
00:00:00 1970 GMT was 01:00:00 1970 in your timezone.
Code: Select all
<?php echo gmdate('H:i:s', 218); ?>
prints
00:03:38
Thanks, works great