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
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?

Edited by nisroc
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.