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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php