Categories > TinyButStrong general >

problem with date ='0000-00-00' when using frm='dd/mm/yyyy'

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: olivier
Date: 2005-01-24
Time: 12:19

problem with date ='0000-00-00' when using frm='dd/mm/yyyy'

When I've got some date with the value '0000-00-00', TBS show the field with the value '30/11/1999'

<input type="text" size=10 name="date_creation" value="[var.date_creation;frm='dd/mm/yyyy']"></input>

I try to specify the format with frm='dd/mm/yyyy|negative|zero|null' to test the display like :
<input type="text" size=10 name="date_creation" value="[var.date_creation;frm='dd/mm/yyyy|negative|zero|null']"></input>

and that's don't work. Any idea without using the 'onformat' tbs tag ?

regards
Olivier
By: Skrol29
Date: 2005-01-24
Time: 16:23

Re: problem with date ='0000-00-00' when using frm='dd/mm/yyyy'

Hello,

Conditional format works only for numeric values.
And also '0000-00-00' is not considered as a zero or null value.

But the following TBS tag works:
[var.date_creation;frm='dd/mm/yyyy';if [val]='30/11/1999';then '(zero)';else [val]]
Note that we need '30/11/1999' instead of '0000-00-00' in the tag because parameter 'frm' is processed before parameter 'if'.

I agree this a is a bit unconfortable, I'll try to make this more friendly in a next version.
By: olivier
Date: 2005-01-24
Time: 17:14

Re: problem with date ='0000-00-00' when using frm='dd/mm/yyyy'

Thanks a lot Skrol for your help.... et bonne continuation

Olivier
By: olivier
Date: 2005-01-26
Time: 11:44

Re: problem with date ='0000-00-00' when using frm='dd/mm/yyyy'

Hello, Skrol,

I think the PHP function 'strtotime' return 30 nov 99 when the input is '0000-00-00'

I've made a test in PHP to avoid this problem

function display_date($db_date)
{
  $display = '';
  switch ($db_date) {
    case '0000-00-00':
    case '0000-00-00 00:00:00':
    case '00:00:00':
      break;
    default:
      $display = date("d/m/Y", strtotime($db_date));
      break;
  }
  return $display;
}