MySQL stores the date in my database (by default) as ‘YYYY-MM-DD’ The field type for my date is ‘DATE’ (I do not need any time storage).. Is there a simple way to change it by default to DD/MM/YYYY ?
I call up different dates in 2 different tables, and no where in any of my code do I have anything resembling a date variable or anything! Hopefully this is a straight forward change?
In PHP, you could :
strtotimeA bit like this, I’d say :
But this will only work for dates between 1970 and 2038, as timestamps are stored as 32 bits integers, counting from 1970-01-01.
In MySQL, I suppose the [`date_format`][4] function would do the trick.
For example :
And, for the sake of completness, another solution, in PHP, that doesn’t suffer from the limitation of 1970-2038 would be to use the `DateTime` class, and, especially :
DateTime::__constructto parse the date returned by the DBDateTime::formatto format the date to whatever format you want.For example, this portion of code :
would get you this output :