Re: Date formatting Question (Beginner)

From: Date: Fri, 09 Jun 2000 14:11:14 +0000
Subject: Re: Date formatting Question (Beginner)
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-288@lists.php.net to get a copy of this message
> I've a date stored in a MySQL table. > When retrieving this date from the DB, I want to output this date in day, > Month Name, Year format. > > I've tried numerous variants of the following code: > $date = $row["task_date"]; > print (date ("d F Y", $date)); You know, when you ask a question like this on a mailing list of thousands, you'll get a thousand different answers. :) You could let MySQL do the work for you: select monthname(task_date) as month, dayofmonth(task_date) as date, year(task_date) as year from .... then when fetching your array, use: $month = $row['month']; $date = $row['date']; $year = $row['year]; There are tons of MySQL date/time related functions that can make lives easier...it's in section 7.4 or soemthing like that. - Julie +------------------------------------------------+ | Julie Meloni | | Tech. Director, i2i Interactive (www.i2ii.com) | | e-mail: jcm@i2ii.com | | | | "PHP Essentials" ... http://www.thickbook.com/ | +------------------------------------------------+

« previous php.db (#288) next »