Twelve hour times
Twelve hour times
I am using the newest version of both DataTables and Editor. I want my Editor input to use something like:
2016-02-11 4:57 pm
(hour w/o leading zero and am/pm)
in my .js file (for the var editor = new $.fn.dataTable.Editor line), I am using:
"format": "YYYY-MM-DD h:mm a"
For my .php Editor::inst( ) I am using:
Field::inst( 'date_attended' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::dateFormat', array( 'format'=>'Y-m-d g:i a' ) )
->getFormatter( 'Format::datetime', array( 'from'=>'Y-m-d g:i a', 'to' =>'Y-m-d g:i a' ) )
->setFormatter( 'Format::datetime', array( 'to' =>'Y-m-d g:i a', 'from'=>'Y-m-d g:i a' ) )
The mysql data type is DATETIME.
Input is successful from the web browser as I am not seeing any "invalid date format" type errors.
Three problems:
1) The data attended column does not display any info.
2) The mysql row contains: 0000-00-00 00:00:00
3) How can I just have :00 :15 :30 :45 for minute selections?
How do I fix these?
Thanks,
-John
Replies
Hi John,
The database will store and get data in ISO8601 format, so you want to use that for the get and set formatters:
That should hopefully resolve 1 and 2.
For 3 you can use the
minutesIncrement
option of thedatetime
field type. Just set it to be 15.Allan
Allan,
I made these changes and got everything working. For 3, I had to also add secondsIncrement to get it working.
Thank you so much for your help. I really appreciate it.
-John