Format::time
Format::time
I have 2 time fields, which are just time, no date. I am trying to figure out the syntax for server side and client side.
I think the js is close to this:
, { "label": "shift start:", "name": "rr_analyst.shift_start"
, format: "HH:mm"
, type: "datetime"
, "fieldInfo": "US style HH:mm format"
}
, { "label": "shift end:", "name": "rr_analyst.shift_end"
, format: "HH:mm"
, type: "datetime"
, "fieldInfo": "US style HH:mm format"
}
I am fairly sure that if they were date time, the server side would need this:
Field::inst('rr_analyst.shift_start')
/* MIGHT NOT BE DONE */
->getFormatter(Format::dateSqlToFormat('m/d/Y'))
->setFormatter(Format::datetime('m/d/Y','Y-m-d'))
->validator(Validate::dateFormat('m/d/Y')),
Field::inst('rr_analyst.shift_end')
/* MIGHT NOT BE DONE */
->getFormatter(Format::dateSqlToFormat('d/m/Y'))
->setFormatter(Format::datetime('d/m/Y','Y-m-d'))
->validator(Validate::dateFormat('d/m/Y')),
But I can find no comments in the docs or forum as to what this should be for time fields. I would like to display as 2 digit hours, 2 digit minutes on a 24 hour clock.. I would like to write to the DB as 2 digit hours, 2 digit minutes, 2 digit seconds on a 24 hour clock. Something like this:
Field::inst('rr_analyst.shift_start')
/* MIGHT NOT BE DONE */
->getFormatter(Format::dateSqlToFormat('h:i'))
->setFormatter(Format::datetime('h:i','h:i:s'))
->validator(Validate::dateFormat('h:i')),
Field::inst('rr_analyst.shift_end')
/* MIGHT NOT BE DONE */
->getFormatter(Format::dateSqlToFormat('h:i'))
->setFormatter(Format::datetime('h:i','h:i:s'))
->validator(Validate::dateFormat('h:i')),
This question has an accepted answers - jump to answer
Answers
Can someone point me to a list of possible formats?
Hi Erik,
On the server-side the formatting strings for the PHP libraries are defined by PHP's date formatter.
On the client-side we support either Moment or Luxon which each define their own formatting:
Allan
Allan, this is fantastic. Another issue I was having resolved.
PHP
JS