note 20155 added to function.mktime
| From: | bohemian_likeu at yahoo dot com dot au | Date: | Mon, 25 Mar 2002 01:03:56 +0000 |
| Subject: | note 20155 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-28153@lists.php.net to get a copy of this message | ||
I borrowed some of this code from one of your contributors above, thankyou!
Beware using mktime on variable driven, user entered dates...especially for months, it took me hours
of frustration and experimentation to realize an "M" needed to be an "m", see
below:
$yr = date("Y");
$mn = date("m"); // Small "m" not BIG "M"
$dy = date("d");
$hr = date("G");
$minute = date("i");
$sec = date("s");
$offset = $dy + $item_duration; // some number of days
$item_deadline = date("G:i M d Y", mktime($hr,$minute,0,$mn,$offset,$yr));
$item_duration was responding with "03 Jan 2002" instead of "03 Apr 2002"
because (apparently) $mn was trying to make a numeric value for the textual M month configuration -
setting dy to date("m"); solved the error.
Hope this helps someone :)
--
http://www.php.net/manual/en/function.mktime.php
http://master.php.net/manage/user-notes.php?action=edit+20155
http://master.php.net/manage/user-notes.php?action=delete+20155
http://master.php.net/manage/user-notes.php?action=reject+20155