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
php date... how do I rearrange this date/time from mysql row
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: php date... how do I rearrange this date/time from mysql row
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
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!
(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!
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: php date... how do I rearrange this date/time from mysql row
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]
[sql]SELECT DATE_FORMAT(`datefield`, '%M %e %Y') AS new_date_formatted FROM `tablename` WHERE `searchcolumn` = 'somevaluetoget';[/sql]