Pontins - Remortgages - Debt Help - Credit Counseling - Credit Cards

PDA

View Full Version : how to subtract one hour from time?


alhen
Jul 31st 2007, 11:46 am
Hello,
I'm hoping there's a really easy way to subtract one hour from the time I'm entereing into my table. the code I have is:
$time = (date ("h:i:s A"));

But the server is in eastern time and I'm in central time.

Please tell me it's easy!

Thanks,
--
alhen

rodney88
Jul 31st 2007, 12:23 pm
You just need to take off 3600 seconds from the timestamp:
$time = date("h:i:s A", time()-3600);

PHP5 has a new date object and timezone handling functions but unless you're working with times a lot, that's probably overkill.

alhen
Jul 31st 2007, 12:27 pm
Thanks rodney88, problem solved!
--
~alhen

nagasharmi
Aug 2nd 2007, 1:49 am
$d=getdate();
echo $d[hours];
echo $d[minutes];
echo $d[seconds];