javascript - Proper way of formatting date/time for MySQL and for View vice versa -


i use backbone laravel.

i have several fields in form date , time ('dd-mm-yyyy', 'hh:mm').

when want save form use own function convert mysql ('yyyy-mm-dd', 'h:i:s') via date() added save() in laravel model class.

but vice versa harder because there no single function in laravel data output. find(), findornew(), findorfail(), ... - there in different classes cant use single place add formatting function.

in case tried format date in frontend seems bad practice.

so way should use? there way format date/time?

if programming environment using expects (or can handle) date strings in format, use mysql functions construct string needed, such date_format().

i not recommend using these functions convert date fields programming environment format in where, on, or having clauses though. one, using string comparison, (and more importantly) defeats indexing benefits might have fields.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -