You are here: Re: convert milliseconds to a time « PHP Programming Language « IT news, forums, messages
Re: convert milliseconds to a time

Posted by Kimmo Laine on 05/09/06 15:19

"Benny Schudel" <bennyschudel@gmail.com> wrote in message
news:1147167140.534509.60260@j73g2000cwa.googlegroups.com...
> hello
>
> I've tried to convert some milliseconds to a time format.
>
> $ms = 100000 // 1min 40sec
> echo strftime('%H:%M:%S', $ms/1000);
>
> i expect the result is: "00:01:40"
>
> but the result ist: "01:01:40"
>
> i think this is a problem of a locale.
> is there another easy way to covert a given ammout of milliseconds to a
> time format?
>


strftime takes a pattern and a timestamp as parameter. The timestamp is
milliseconds since the EPOCH time, January 1, 1970 at midnight at GMT. Now
my guess is that the one hour leap comes from the fact that you live in a +1
timezone and the +1 hour is being accounted for when you use strftime. I
tried the same script and just as expected I got 02:01:40 since Helsinki is
in GMT+2 timezone.

I didn't test, but I'd guess the sisterfunction of strftime, gmstrftime
would do the trick since it assumes GMT time is being used and doesn't add
any timezone hours to the time. Therefore it might provide a solution.

--
"ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" -lpk
spam@outolempi.net | Gedoon-S @ IRCnet | rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация