CodeIgniter Forums
how to change date format - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: how to change date format (/showthread.php?tid=35501)



how to change date format - El Forum - 11-01-2010

[eluser]Unknown[/eluser]
i have tabel in mysql databases in coloum date already set date like 2005/05/01 ( year/month/date) can you help me . i'd like to change date/month/year


how to change date format - El Forum - 11-01-2010

[eluser]Tominator[/eluser]
No way man! Big Grin

Really you can't change how it's stored, but you can't change how it will be dumped via DATE_FORMAT() function.


how to change date format - El Forum - 11-01-2010

[eluser]jrtashjian[/eluser]
I normally store dates as a timestamp in the database and use PHP's date() to format it. Makes everything easier. I know you can use DATE_FORMAT() to format it directly in MySQL however, I'm pretty sure you can only store dates using the "-" separator not the "/". Which tells me you're most likely storing the date in a varchar() column and not a date() column.


how to change date format - El Forum - 11-01-2010

[eluser]Tominator[/eluser]
Use DATE_FORMAT() - it's faster:
http://www.onextrapixel.com/2010/06/23/mysql-has-functions-part-5-php-vs-mysql-performance/


how to change date format - El Forum - 11-01-2010

[eluser]danmontgomery[/eluser]
[quote author="jrtashjian" date="1288637854"]Which tells me you're most likely storing the date in a varchar() column and not a date() column.[/quote]

This. Mysql's date format is Y-m-d. You can't perform Mysql's native date functions unless the column is a date type (date, datetime, timestamp)... It will also accept YYYYMMDD, but not MM/DD/YYYY