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)
[Back to original message]
|