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
?
Asked
Active
Viewed 1,145 times
1

Danish Ali
- 2,354
- 3
- 15
- 26
-
try using date format function in php – Anu Jun 06 '18 at 06:34
2 Answers
2
The internal storage format of dates in MySQL is usually out of scope for developers and most users of the database. Basic good practice is to always store date information using a proper date column, such as datetime
. With regard to how to view your date information in different ways, you may use the DATE_FORMAT
function. For example:
SELECT DATE_FORMAT('2014-02-01', '%d/%m/%Y') AS new_date
FROM dual;
01/02/2014

Tim Biegeleisen
- 502,043
- 27
- 286
- 360
0
Simply use date()
and strtotime()
date('d/m/Y', strtotime('now'));
OR
date('d-m-Y', strtotime('now'));
OUTPUT
06/06/2018
06-06-2018

Danish Ali
- 2,354
- 3
- 15
- 26