Page 1 of 1

Time comparison issue

Posted: Sun Apr 13, 2008 9:45 am
by jaydrawmer
Hi All,

I've been searching around the internet for time/date comparisons, and to my 1st amazement, there was no built-in functionality... Secondly, there doesn't appear to be what I want to do.

I have 1 value which is the timestamp of when something began... I have another timestamp which is how long something takes, and I want to work out the finishing timestamp.

Either that or solve this problem...

I'm developing an online strategy game, and you will, for example, upgrade a building which might take 25 minutes. I'm also running alongside it, javascript which will show on teh screen how long something takes until it is complete. My initial thought was to run the same code in php as javascript, so the javascript is showing the user how long something will take, but only when the page is refreshed, the php will actually work it out and show you the next screen.

Hope this makes sense.

Regards,
Jason

Re: Time comparison issue

Posted: Sun Apr 13, 2008 10:16 am
by Weirdan
I have 1 value which is the timestamp of when something began... I have another timestamp which is how long something takes,
I guess the second value you have is duration in seconds, not a timestamp.
and I want to work out the finishing timestamp.
Just add a duration to the start timestamp:

Code: Select all

 
$start = time();
$duration = 30; // seconds
$end = $start + $duration;