Re: Dates Again

From: Date: Mon, 31 Mar 2008 21:45:39 +0000
Subject: Re: Dates Again
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-272360@lists.php.net to get a copy of this message
Zoltán Németh wrote:
VamVan írta:
Hello All, I have a date in 2008-03-29 12:15:00 format. - How can I reduce one day from it? - How can I reduce one hour from it? - How can I add 1 hour to today's date? Thanks
just convert it to a timestamp with strtotime() then you can manipulate it by adding/substracting - 86400 for a day - 3600 for an hour then convert back with strftime() http://hu.php.net/strtotime http://hu.php.net/strftime greets, Zoltán Németh
I believe you can also use strtoime() http://us.php.net/manual/en/function.strtotime.php $time = strtotime($inputTime); $time = strtotime('-1 day', $time); $outputTime = strftime('%Y-%m%d', $time); I'm not sure which is more efficient, but it helps when you're looking for "next thursday" or other things like that. -- Ray Hauge www.primateapplications.com

« previous php.general (#272360) next »