Solved

SUPER EASY php mysql date display

Posted on 2008-06-10
4
236 Views
Last Modified: 2008-06-10
how do you take a date variable from a mysql database and display it in the date format you choose?
ie.
$db_date=mysql_result($result,$i,"db_date");
$formated_date=$db_date(M,d,Y);
0
Comment
Question by:newbe101
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 21752424
use strtotime and date

$formated_date = date('M,d,Y', strtotime(mysql_result($result,$i,"db_date")));

See http://www.php.net/date and http://www.php.net/strtotime

how does the date from the db look?
0
 
LVL 14

Expert Comment

by:ali_kayahan
ID: 21752429
$date = date("M,d,Y",$db_date) ;
0
 
LVL 14

Expert Comment

by:ali_kayahan
ID: 21752432
It will work if you populate your field with time()
0
 

Author Comment

by:newbe101
ID: 21752497
Thank you again, hernst42 !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question