diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fa606639bcc..9cba6ed839e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4775,7 +4775,7 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0). + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty @@ -4813,7 +4813,7 @@ class Form } // Analysis of the pre-selection date - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) // deprecated usage { // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' $syear = (! empty($reg[1])?$reg[1]:''); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index a53f812611a..0250bb2c39f 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -28,11 +28,16 @@ This page is a sample of page using Dolibarr HTML widget methods. It is designed $form=new Form($db); // Test1: form->select_date using tzuser date -print "Test 1: We must have here current hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; +print "Test 1a: We must have here current date and hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")
\n"; -$form->select_date('', 'test1', 1, 1, 0); +$form->select_date(dol_now(), 'test1a', 1, 1, 0); + +print '

'."\n"; + +print "Test 1b: We must have here current date with hours to 00:00.
"; +$form->select_date('', 'test1b', 1, 1, 0); print '

'."\n";