By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,796 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

Displaying DATE or DATETIME in PHP

P: n/a
Hello,

I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007

Thank you,

Colleen Robledo

Oct 16 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Tue, 16 Oct 2007 09:42:28 +0200, Colleen Robledo, MLIS
<co************@gmail.comwrote:
Hello,

I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007
You are better of using the DATE_FORMAT(date_field, '%M %e, %Y') function
in MySQL, as it knows for sure what date it is:
http://dev.mysql.com/doc/refman/5.0/...on_date-format

However, would you wish to do it in PHP, look at these:
http://www.php.net/strtotime
http://www.php.net/date
http://www.php.net/strftime
--
Rik Wasmus
Oct 16 '07 #2

P: n/a
<comp.lang.php>
<Colleen Robledo, MLIS>
<Tue, 16 Oct 2007 07:42:28 -0000>
<11*********************@e9g2000prf.googlegroups.c om>
I'm still pretty new to PHP and MySQL, and have a PHP scripting
question.

If I'm querying DATE info from a MySQL database, and displaying it
with PHP echo statements... is there a PHP script I can use to convert
the DATE data to standard calendar format?

Example:

2007-10-12 displayed as October 12, 2007
<?php

$lager="2007-10-12";

$beer=explode('-',$lager);

$drink=date("F-d-Y",mktime(0,0,0,$beer[1],$beer[2],$beer[0]));

print "The converted date is $drink <br>";

?>
--
www.vhit.co.uk
www.jpgimage.co.uk
www.phpwhois.co.uk
www.cannabiswindow.co.uk
Oct 17 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.