note 35691 added to function.date

From: Date: Thu, 11 Sep 2003 09:33:24 +0000
Subject: note 35691 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-56058@lists.php.net to get a copy of this message
In reply to 'SARGe at poopshovel dot com' post Why make things so hard? What you have there can be summed up with: <code> // Date And Days $from_date = '2003-08-27'; $days = 14; // Create Start UTStamp $start = strtotime( $from_date . '-' . $days . ' days' ); // Create End UTStamp $end = strtotime( $from_date . '+' . $days . ' days' ); echo( date( 'Y-m-j', $start ) ); // outputs -> 2003-08-13 echo( date( 'Y-m-j', $end ) ); // outputs -> 2003-09-10 </code> I used 14 as the days + and -, but using strtotime() as above, you can use any amount of days, weeks, months, years, etc. (after the epoch and before something like 2038 or somewhere around there) with no need to worry about leap year and the other factors. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35691 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35691&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35691&report=yes

« previous php.notes (#56058) next »