CURRENT_DATE() saving in different format

Asked

Viewed 37 times

0

inserir a descrição da imagem aqui

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

  • 1

    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 class DateTime.

  • 1

    I could not understand it. This function current_time generates a PHP date and you save in a varchar field?

  • that’s right, Wallace (a fix, I used CURRENT_DATE())

  • Dude I think it’s right that you use a field like date or even datetime and use the now() of mysql in your Insert query

  • 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, 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''

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.