note 42843 deleted from ref.datetime by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 31 May 2004 21:31:50 +0000 |
| Subject: | note 42843 deleted from ref.datetime by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-70366@lists.php.net to get a copy of this message | ||
Note Submitter: philip@kimco.ca
----
Some notes about functions to add time interval to a timestamp
If using the functions proposed by
vincentv at thevoid dot demon dot nl on 19-Nov-2003 10:56
we run into trouble if we just want to add a month
i.e. 2004-5-31 the concept of the same date from the previous months is unclear
if all we need is any day of the previous or next month here is a function
to add arbitrary month number(positive/negative to a given timestamp)
<?
/**
* modifies the current timestamp by $montsh months and sets day field to 1 and time to 0
* @access public
* @return void
**/
function addMonth($time_stamp,$months){
$timePieces = getdate($time_stamp);
return mktime( 0,
0,
0,
$timePieces["mon"] + $months,
1,
$timePieces["year"] );
}
?>