reformate date comes from json
reformate date comes from json
hanyelbana
Posts: 24Questions: 0Answers: 0
Hi,
my
{ "mData": "created_at" }
return
2013-09-08 06:13:56
and I need to display only the date without time
How can I do that?
Thanks
my
{ "mData": "created_at" }
return
2013-09-08 06:13:56
and I need to display only the date without time
How can I do that?
Thanks
This discussion has been closed.
Replies
http://editor.datatables.net/docs/current/php/class-DataTables.Editor.Field.html#_getFormatter
http://editor.datatables.net/docs/current/php/class-DataTables.Editor.Field.html#_setFormatter
There are some helper date formatter functions built into the Editor libraries: http://editor.datatables.net/docs/current/php/class-DataTables.Editor.Format.html ( `DATE_ISO_8601` for example might be what you want).
Regards,
Allan
Allan
I do not set the date, I only read it from the data base.
Please give me example, how can I change this row to format the display date:
{ "mData": "created_at" }
[code]
Editor::inst( $db, 'users' )
->fields(
Field::inst( 'first_name' ),
Field::inst( 'last_name' ),
Field::inst( 'updated_date' )
->validator( 'Validate::dateFormat_required', array(
"format" => Format::DATE_ISO_8601,
"message" => "Please enter a date in the format yyyy-mm-dd"
) )
->getFormatter( 'Format::date_sql_to_format', Format::DATE_ISO_8601 )
->setFormatter( 'Format::date_format_to_sql', Format::DATE_ISO_8601 ),
Field::inst( 'registered_date' )
->validator( 'Validate::dateFormat', 'D, d M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, d M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, d M y' )
)
->process( $_POST )
->json();
[/code]
Allan