note 20155 deleted from function.mktime by hholzgra

From: Date: Sun, 14 Apr 2002 21:54:02 +0000
Subject: note 20155 deleted from function.mktime by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-29318@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 :)

« previous php.notes (#29318) next »