diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php
index 37376aceb7a..806ca6fa5ad 100644
--- a/htdocs/compta/bank/fiche.php
+++ b/htdocs/compta/bank/fiche.php
@@ -325,7 +325,7 @@ if ($action == 'create')
print '
| '.$langs->trans("Date").' | ';
print '';
- $form->select_date(time(), 're', 0, 0, 0, 'formsoc');
+ $form->select_date('', 're', 0, 0, 0, 'formsoc');
print ' |
';
print '| '.$langs->trans("BalanceMinimalAllowed").' | ';
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 452d0e7110d..5943d451b9c 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2915,16 +2915,17 @@ class Form
}
/**
- * Show a form to select a date
+ * Show a form + html select a date
*
* @param string $page Page
* @param string $selected Date preselected
- * @param string $htmlname Name of input html field
+ * @param string $htmlname Html name of date input fields or 'none'
* @param int $displayhour Display hour selector
* @param int $displaymin Display minutes selector
* @return void
+ * @see select_date
*/
- function form_date($page, $selected, $htmlname,$displayhour=0,$displaymin=0)
+ function form_date($page, $selected, $htmlname, $displayhour=0, $displaymin=0)
{
global $langs;
@@ -3437,13 +3438,13 @@ class Form
/**
- * Show a HTML widget to input a date or combo list for day, month, years and optionnaly hours and minutes
+ * Show a HTML widget to input a date or combo list for day, month, years and optionnaly hours and minutes.
* Fields are preselected with :
- * - set_time date (Local PHP server timestamps or date format YYYY-MM-DD or YYYY-MM-DD HH:MM)
- * - local date of PHP server if set_time is ''
- * - Empty (fields empty) if set_time is -1 (in this case, parameter empty must also have value 1)
+ * - set_time date (must be a local PHP server timestamp or string date with format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM')
+ * - 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)
+ * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date.
* @param string $prefix Prefix for fields name
* @param int $h 1=Show also hours
* @param int $m 1=Show also minutes
@@ -3455,6 +3456,7 @@ class Form
* @param int $disabled Disable input fields
* @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59
* @return mixed Nothing or string if nooutput is 1
+ * @see form_date
*/
function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowbutton=0, $nooutput=0, $disabled=0, $fullday='')
{
@@ -3467,7 +3469,11 @@ class Form
if($m == '') $m=0;
if($empty == '') $empty=0;
- if (! $set_time && $empty == 0) $set_time = dol_now('tzuser');
+ if ($set_time === '' && $empty == 0)
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+ $set_time = dol_now('tzuser')-(getServerTimeZoneInt('now')*3600); // set_time must be relative to PHP server timezone
+ }
// Analysis of the pre-selection date
if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg))
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index bf398c389c0..c3889a41456 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -1058,7 +1058,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
/**
- * Return date for now. We should always use this function without parameters (that means GMT time)
+ * Return date for now. In mot cases, we use this function without parameters (that means GMT time).
*
* @param string $mode 'gmt' => we return GMT timestamp,
* 'tzserver' => we add the PHP server timezone
@@ -1068,7 +1068,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
*/
function dol_now($mode='gmt')
{
- // Note that gmmktime and mktime return same value (GMT) whithout parameters
+ // Note that gmmktime and mktime return same value (GMT) when used without parameters
//if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead
if ($mode == 'gmt') $ret=time(); // Time for now at greenwich.
else if ($mode == 'tzserver') // Time for now with PHP server timezone added
@@ -1083,7 +1083,7 @@ function dol_now($mode='gmt')
$tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time
$ret=dol_now('gmt')+($tzsecond*3600);
}*/
- else if ($mode == 'tzuser') // Time for now with user timezone is added
+ else if ($mode == 'tzuser') // Time for now with user timezone added
{
//print 'eeee'.time().'-'.mktime().'-'.gmmktime();
$offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60;
diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php
index 89b257ca817..4857523aaf5 100644
--- a/htdocs/cron/card.php
+++ b/htdocs/cron/card.php
@@ -303,11 +303,13 @@ if (($action=="create") || ($action=="edit"))
print "
| ";
print $langs->trans('CronHourStart')." | ";
- if(!empty($object->datestart)){
+ if(!empty($object->datestart))
+ {
$form->select_date($object->datestart,'datestart',1,1,'',"cronform");
}
- else{
- $form->select_date(dol_now(),'datestart',1,1,'',"cronform");
+ else
+ {
+ $form->select_date('','datestart',1,1,'',"cronform");
}
print " | ";
print "";
diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php
index fb8274e5524..f7e29a695a1 100644
--- a/htdocs/public/test/test_arrays.php
+++ b/htdocs/public/test/test_arrays.php
@@ -131,11 +131,8 @@ Example 1 : Table using tags: div.tagtable+div.tagtr+div or div.tagtable+div.tag
Example 2 : Table using tags: table/thead/tbody/tr/td + dataTable
-
+
| snake |
@@ -274,4 +271,4 @@ Example 3 : Standard table
|