note 95574 added to function.date-add
| From: | lanlife4real at osu1 dot php dot net | Date: | Sun, 10 Jan 2010 11:19:19 +0000 |
| Subject: | note 95574 added to function.date-add | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164826@lists.php.net to get a copy of this message | ||
This function allows the addition of day(s),month(s),year(s) to the original date while still
preserving the Hours, minutes and seconds
You can also modify to add to hours, miuntes and even seconds.
<?php
function add_date($givendate,$day=0,$mth=0,$yr=0) {
$cd = strtotime($givendate);
$newdate = date('Y-m-d h:i:s', mktime(date('h',$cd),
date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
date('d',$cd)+$day, date('Y',$cd)+$yr));
return $newdate;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 41.184.16.108
----
Manual Page -- http://www.php.net/manual/en/function.date-add.php
Edit -- https://master.php.net/note/edit/95574
Del: integrated -- https://master.php.net/note/delete/95574/integrated
Del: useless -- https://master.php.net/note/delete/95574/useless
Del: bad code -- https://master.php.net/note/delete/95574/bad+code
Del: spam -- https://master.php.net/note/delete/95574/spam
Del: non-english -- https://master.php.net/note/delete/95574/non-english
Del: in docs -- https://master.php.net/note/delete/95574/in+docs
Del: other reasons-- https://master.php.net/note/delete/95574
Reject -- https://master.php.net/note/reject/95574
Search -- https://master.php.net/manage/user-notes.php