| | |
reformatting MySQL date (yyyy-mm-dd)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hey, I need help getting that ugly yyyy-mm-dd format to change to something prettier. I would prefer being able to output it in the form like January 01, 2007. Something easy to read for the average user. I can leave it stored in yyyy-mm-dd in my database, but in my output I'd like to reformat it.
Any pointers?
Any pointers?
Well, after some searching around, I found this bit of code that can be used in the SELECT function that works for me:
[PHP]
SELECT date_format(my_date, '%M %e, %Y') as date, FROM my_table
[/PHP]
It then stores the date in the format I want in the variable called "date".
Thanks.
[PHP]
SELECT date_format(my_date, '%M %e, %Y') as date, FROM my_table
[/PHP]
It then stores the date in the format I want in the variable called "date".
Thanks.
Last edited by nathanpacker; Jan 6th, 2007 at 8:46 am.
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
Yes, exactly. Although there's no difference as far as the performance is concerned, personally I prefer to leave the data formatting to php rather than mysql, simply for the sake of responsibility separation.
![]() |
Other Threads in the PHP Forum
- Previous Thread: How do i display records of an item into textbox based on drop down list
- Next Thread: php and dom? (dommitall).
| Thread Tools | Search this Thread |
ajax apache api array basics beginner binary broken cakephp checkbox class cms code codingproblem combobox cron curl database date display domain dynamic echo email error file files folder form format forms function functions google href htaccess html image include insert interactive ip java javascript joomla js limit link load login mail malfunctioning menu mlm mobile multiple mysql nodes oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion reference remote return script search server sessions sms source space sql syntax system table tutorial unset up-to-date update upload url validation validator variable video web webapplications websitecontactform youtube






