DateTime field Issues
Posted: 2018-06-06 21:10
Hello everybody,
I have tried, without success, to show dates in UK format, however nothing I try works. I am using Appgini Version 5.62.
I have set my preference as UK format in my app, and it works fine with date fields, but not with DateTime fields, these fields keep presenting the US date and time format. Data format for each field is chosen as Default
I have tried setting my preferences as US format and choosing the Data Format for each field as UK format, This causes an error on some fields controlled by a script in a hook (it writes 0000-00-00 00:00:00, instead of the actual date time).
The script that writes on the DateTime fields is in the hooks/orden.php file and it is in the before_insert and before_update functions:
function orden_before_insert(&$data, $memberInfo, &$args){
$preporini = $data['prep_orden'];
$servorini = $data['serv_orden'];
$tim_stamp=date('Y-m-d G:i:s');
$estorden = $data['estado_orden'];
if($estorden == 'Preparada' && !$preporini){
$data['prep_orden'] = $tim_stamp;
}else if ($estorden == 'Servida' && !$servorini){
$data['serv_orden'] = $tim_stamp;
}else {
$data['serv_orden'] = $servorini;
$data['prep_orden'] = $preporini;
}
return TRUE;
}
Something else, the variable: $tim_stamp=date('Y-m-d G:i:s'); only works when I use this format, if I use this one: $tim_stamp=date('d/m/Y H:i:s'); it won´t work, the output is always 0000-00-00 00:00:00.
Can anybody know why is this happening.
I have tried, without success, to show dates in UK format, however nothing I try works. I am using Appgini Version 5.62.
I have set my preference as UK format in my app, and it works fine with date fields, but not with DateTime fields, these fields keep presenting the US date and time format. Data format for each field is chosen as Default
I have tried setting my preferences as US format and choosing the Data Format for each field as UK format, This causes an error on some fields controlled by a script in a hook (it writes 0000-00-00 00:00:00, instead of the actual date time).
The script that writes on the DateTime fields is in the hooks/orden.php file and it is in the before_insert and before_update functions:
function orden_before_insert(&$data, $memberInfo, &$args){
$preporini = $data['prep_orden'];
$servorini = $data['serv_orden'];
$tim_stamp=date('Y-m-d G:i:s');
$estorden = $data['estado_orden'];
if($estorden == 'Preparada' && !$preporini){
$data['prep_orden'] = $tim_stamp;
}else if ($estorden == 'Servida' && !$servorini){
$data['serv_orden'] = $tim_stamp;
}else {
$data['serv_orden'] = $servorini;
$data['prep_orden'] = $preporini;
}
return TRUE;
}
Something else, the variable: $tim_stamp=date('Y-m-d G:i:s'); only works when I use this format, if I use this one: $tim_stamp=date('d/m/Y H:i:s'); it won´t work, the output is always 0000-00-00 00:00:00.
Can anybody know why is this happening.