Mindhunter wrote:
> 
> Hi,
> 
> I am reading a date from an input in format 'DD-MM-YYYY' ex. 10-11-2001.
> Now I want to add 3 months to the date.  I have tested mktime and strftime
> etc and no matter what I do I get the year as 1970.  (Systemdate works
> fine).  How would I go about adding 3 months to a date in that format?
> 
> Thanks
> MH
The following works for me:

$mydate = '10-11-2001';

list($myday,$mymonth,$myyear) = explode('-',$mydate);

$mymktime = mktime(0,0,0,3 + $mymonth,$myday,$myyear);

$newdate = date('d-m-Y',$mymktime);

newdate is then 10-02-2002

You might check : 
1. You always use a 4 digit year
2. mktime order of arguments i.e. hours,minutes,seconds,months,days,years 
3. Output date format on date() function
4. There are problems with dates pre 1970 AND pre 1901, (pre 1970 is pre unixtime, pre 
1901 is pre
phptime).  I had problems with pre 1901 dates which the calendar module solved ( see 
jdtojulian,
juliantojd)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to