Page 1 of 1
php date... how do I rearrange this date/time from mysql row
Posted: Wed Jun 04, 2008 12:04 pm
by syntax24
I need to know how to format this time listed below into a webpage using php. It's the time used in the mysql table row... and I want to format it in a more userfriendly way. Can PHP pull that out of lastLogin and recognize it as a date/time?
2008-06-03 15:07:24
Re: php date... how do I rearrange this date/time from mysql row
Posted: Wed Jun 04, 2008 12:45 pm
by RobertGonzalez
PHP can do it, but it would be faster/more efficient to modify using the MySQL date functions during the select.
Re: php date... how do I rearrange this date/time from mysql row
Posted: Wed Jun 04, 2008 1:22 pm
by syntax24
umm... alright so if the row is a "datetime" format.... how do I modify it using sql query while pulling the data from a table...
(I am somewhat new to the whole sql query to modify date thing)...
if you could give me just a little bit more help, I'd appreciate it alot!
Thanks!
Re: php date... how do I rearrange this date/time from mysql row
Posted: Wed Jun 04, 2008 1:28 pm
by RobertGonzalez
Depending on how you want your date to look (have a look through
the MySQL docs on Date and Time functions), you would do something like (in MySQL only):
[sql]SELECT DATE_FORMAT(`datefield`, '%M %e %Y') AS new_date_formatted FROM `tablename` WHERE `searchcolumn` = 'somevaluetoget';[/sql]