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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.