Displaying DATE or DATETIME in PHP

Displaying DATE or DATETIME in PHP

am 16.10.2007 09:42:28 von colleenrobledo

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

Re: Displaying DATE or DATETIME in PHP

am 16.10.2007 09:50:42 von luiheidsgoeroe

On Tue, 16 Oct 2007 09:42:28 +0200, Colleen Robledo, MLIS
wrote:

> 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/en/date-and-time-functio ns.html#function_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

Re: Displaying DATE or DATETIME in PHP

am 17.10.2007 14:35:38 von Hans-Peter Sauer




<1192520548.186275.44610@e9g2000prf.googlegroups.com>

> 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
>


$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
";

?>


--
www.vhit.co.uk
www.jpgimage.co.uk
www.phpwhois.co.uk
www.cannabiswindow.co.uk