0
At the bank, the data
is in a varchar
, I simply use CURRENT_DATE()
to save the date to the bank.
But it looks like he’s saving in a different format inside the bank, depending on the month, something really weird.
How to save in a defined pattern?
DD/MM/YYY
, for example
The ideal is to save the date as
date
(not to have problems with sorting), at the time of recording or display to do the conversion, with the functions,date(), strtotime()
or the classDateTime
.– rray
I could not understand it. This function
current_time
generates a PHP date and you save in a varchar field?– Wallace Maxters
that’s right, Wallace (a fix, I used CURRENT_DATE())
– chocolatemontana
Dude I think it’s right that you use a field like
date
or evendatetime
and use thenow()
ofmysql
in your Insert query– periotto
I am providing to change to date type. is there any way to save it in a given format? I made a test table and created the date type date, I realized that mysql only accepts YYYY-MM-DD format, but would like to save as DD/MM/YYYY
– chocolatemontana
@chocolatemontana, the American format is standard, the data in the bank is in English, at the time of presenting vc format it, you can do it in the first query: SELECT DATE_FORMAT(field_data,'%d/%m/%Y') as 'DATA''
– Ivan Ferrer