Jump to content

Date format


moisesbr

Recommended Posts

Hi, I have some doubts as date  format is displayed is 2013-07-25  yy/mm/dd, as it is in database.

 

1-How/is it possible to format dd/mm/yy in database ?

 

2-How to format dd/mm/yy in HTML.

3- Is it right to format it 
dd/mm/yy  in database, or is it mandatory it to be  yy/mm/dd and being formated at display moment ?

Regards

Moises

Link to comment
https://forums.phpfreaks.com/topic/280566-date-format/
Share on other sites

Continue to save dates in your database as yyyy-mm-dd as other formats are useless for date comparisons, sorting and use of mysql date functions.

 

To output as dd/mm/yy you have 2 options

 

1. format in the query using DATE_FORMAT() function in mysql

 

SELECT DATE_FORMAT(datefield, '%d/%m/%y') as date ...

 

2. use php date() function

 

echo date('d/m/y', strtotime($dbdate));
Link to comment
https://forums.phpfreaks.com/topic/280566-date-format/#findComment-1442393
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.