Solved

SUPER EASY php mysql date display

Posted on 2008-06-10
4
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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 dynamically set the form action using jQuery.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

696 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