Hi all,
I have found this code that is supposedly meant to be used for a dateadd
function. I only need it for the adding of days, my problem is that it
doesnt validate when adding days at the end of the month. eg:
march 31 and the I add 2 days is meant to return april 2. But it returns
March 33.
here is the code:
function DateAdd($interval, $number) {
$datearray = getdate();
$hours = $datearray['hours'];
$minutes = $datearray['minutes'];
$seconds = $datearray['seconds'];
$month = $datearray['mon'];
$day = $datearray['mday'];
$year = $datearray['year'];
switch ($interval) {
case 'yyyy':
$year+=$number;
break;
case 'q':
$year+=($number*3);
break;
case 'm':
$month+=$number;
break;
case 'y':
case 'd':
case 'w':
$day+=$number;
break;
case 'ww':
$day+=($number*7);
break;
case 'h':
$hours+=$number;
break;
case 'n':
$minutes+=$number;
break;
case 's':
$seconds+=$number;
break;
}
$timestamp= mktime(0,0,0,$month,$day,$year);
return $timestamp;
}
What i want to know is if anyone can point me to a place where i can get
proper code that validates that it cant add more days for the end of a month
and must rather add the days for the next month. I dont really want to
reinvent the wheel.
thanx in advance
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php