PDA

View Full Version : handling the date and time


mrjameer
05-02-2007, 07:42 PM
hi,


i have a table in which there are 2 fields
1.id
2.date.

values
1 2005-07-28 15:07:52

the time is 3:07:52.

here what i want to do is i want to add 8 hours to the above time
(result should be like 2005-07-28 11:07:52 PM).if it exceeds the date just take next day's date.any of your help will be surely appreciated.

thanks
mrjameer

Fumigator
05-02-2007, 08:07 PM
Use mktime() along with strtotime() to turn that timestamp into a unix timestamp, and then add 8 hours to it (in seconds-- there are 60 minutes in an hour and 60 seconds in a minute so 8 * 60 * 60 gives you the number of seconds in 8 hours).

Then use date() to format the value how you want.