Hello Guys,
I am working on a project that involves loads of date /time manipulation. And I need to be able to add/sub days/months/years from a date object or string. But I cant find a suitable function that works. i have seen some scripts using the "add_delta_ymd()" function or "date_add()" function, but they both dont seem to work on my apache server(localhost). I was wondering if there's another way or maybe I am doing something wrong.
I am using apache 2.2.8 and php 5.2.6.
sample code
--------------------------------------------------------------
$t = date("Y-m-d");
$next_day = date_add($t, 0, 0, 1);
echo "next_day";
--------------------------------------------------------------
Thanks
Date time functions
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Date time functions
Code: Select all
$date = strtotime('1-Mar-2008');
$yesterday = strtotime('-1 day',$date);
$tomorrow = strtotime('+1 day',$date);
echo 'Yesterday was '.date('d-M-Y',$yesterday).'<br />';
echo 'Tomorrow will be '.date('d-M-Y',$tomorrow).'<br />';
Re: Date time functions
Thanks alot.