Jump to content

mySQL date


nisroc

Recommended Posts

I have a mysql date 0000-00-00 in a database of 3000+ entries but on my page i would perfer it to write out as Y-M-d or even d-M-Y. I have flipped though some examples but they all seem to adjust the date before it goes into the database. All i want is it to more clear which will allow easier sorting. is it possible to change the date as it is pull from a database? 

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

 

You can change the date in your MySQL queries using the DATE_FORMAT function, eg

SELECT DATE_FORMAT(your_date_col, 'Y-M-d') as formatted_date FROM table

 

I found an example on the internet which seemed to work Ch0cu3r.  

 

<?php echo date('F d, Y', strtotime($row_draws['Date'])); ?>

I am unsure if this is correct but it does not throw an error, is there anything wrong with using this?

Link to comment
https://forums.phpfreaks.com/topic/284951-mysql-date/#findComment-1463309
Share on other sites

@Ritual29, the nonspecific answer you have provided has already been given, with much greater detail, with the name of the function, a link to its documentation, and an example, in a previous reply in this thread. please don't parrot answers already in the thread unless you are adding helpful information to the thread.

Link to comment
https://forums.phpfreaks.com/topic/284951-mysql-date/#findComment-1463934
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.