Page 1 of 1

Adding/Calculating time with php.

Posted: Thu Jan 29, 2004 6:41 am
by nickuss04
Hi,

I'm a newbie here and reletivly new to php, i hope any of you can help.

What im wanting to do is show two times on a web page. The first time is the time that is taken from the server with the date() function, the second is a calculated time. (ie. calculating the time of one country from the server time of the other).

Can anyone suggest some PHP code to take the time from the server and add 5 hours to it while still displaying the proper AM or PM and reseting the hour back to 1 oclock after it go's past 12 oclock. The date dunction that im using is date(g:i A) to show eg. "3:45 PM".

If anybody could help, that would be great.

Cheers...Nickuss.

Posted: Thu Jan 29, 2004 2:21 pm
by Derfel Cadarn
Before asking others to code for you. I'd suggest you read time and date functions in the php-manual. You could play a bit with those?!? :lol:

Posted: Thu Jan 29, 2004 2:34 pm
by pickle
Definitely look at the php manual. One piece of advice I can give you is do all your adding/subtracting to the UNIX timestamp, rather than a prettily formatted date. It's much easier to work with and you don't have to worry about noon/midnight rollovers.