note 42843 added to ref.datetime

From: Date: Mon, 31 May 2004 20:38:31 +0000
Subject: note 42843 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-70362@lists.php.net to get a copy of this message
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"] ); } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42843 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42843&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42843&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70362) next »