mysql covert time

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bkchf123
Forum Newbie
Posts: 11
Joined: Mon Jan 25, 2010 3:01 pm

mysql covert time

Post by bkchf123 »

I have this
  • date_added: 2010-01-26 14:14:23
    date_updated: 2010-01-26 14:23:38
I want this
  • date_added: 1-26-2010 4:14(am or pm)
    date_updated: 1-26-2010 4:23(am or pm)
here is the code

Code: Select all

 
<?php echo($row_WADAspecials['date_added']); ?>
<?php echo($row_WADAspecials['date_updated']); ?>
 
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: mysql covert time

Post by AbraCadaver »

Look at the manual for date() for the proper format for your needs:

Code: Select all

echo date('your format', strtotime($row_WADAspecials['date_added']));
Or you can use the MySQL DATE_FORMAT() in your query if using MySQL.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
bkchf123
Forum Newbie
Posts: 11
Joined: Mon Jan 25, 2010 3:01 pm

Re: mysql covert time

Post by bkchf123 »

thanks allset
Post Reply