Reply to Re: OT: PHP elapsed time question...

Your name:

Reply:


Posted by Noozer on 03/25/06 13:25

"Roman" <news12@ziak.com> wrote in message
news:VZ8Vf.3928$Hk1.3889@read1.cgocable.net...
> Noozer wrote:
>> I've got a PHP question (it's my first PHP script)... Hopefully there's a
>> quick answer.
>>
>> Why does the following show a 17 hour difference when the "Some Stuff"
>> code
>> actually takes only 42 seconds?
>>
>> For output I get:
>> Elapsed time was 17:00.42.
>>
>>
>> <?php
>>
>> $start_time = mktime();
>>
>> //42 seconds of some stuff happening here
>>
>> $finish_time = mktime();
>>
>> echo "Elapsed time was ".(date("G:i.s",$finish_time-$start_time)).".";
>>
>> ?>
>
> In my opinion the problem is that date() function returns local time. So
> if you supply with integer number 42, that would translate into January
> 1 1970 00:00:42 GMT, but your timezone is GMT+17 or GMT-7 hours, so
> that's where it comes from. Try gmdate().

My problem was thinking that a timestamp of 0 = "00/00/00 00:00:00" but
instead means "1969/??/?? 17:??:??"

What I was really trying to do was find the number of seconds between two
timestamps and format it in HH:MM:SS. I didn't know that timestamps were
actually measured in seconds either.

"$finish_time-$start_time" gives me the number of seconds between two
stamps, which is good enough. I would like to know if there is a simple way
format it out to "HH:MM:SS" (i.e. 123 seconds would output "00:02:03")

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

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