Page 1 of 1

Displaying date as text

Posted: Wed Jul 11, 2007 10:00 am
by aceconcepts
Hi,

I have dates stored in a database I have extracted all of them and displayed them on a page.

However, I would like to display the date as a day textually.

How can I do this?

I've tried the following:

Code: Select all

echo date("l", $sessionDate);
but this displays the same day for each in the loop.

Posted: Wed Jul 11, 2007 10:38 am
by Zoxive
What is the format of $sessionDate ?

It needs to be a timestamp.

So either have mysql pull it out as a timestamp, or convert it.

Code: Select all

echo date('l',strtotime($sessionDate)); // But this still depends how $sessionDate is formated

Posted: Wed Jul 11, 2007 10:41 am
by aceconcepts
$sessionDate is currently formatted as date (0000-00-00)

Posted: Wed Jul 11, 2007 11:08 am
by Zoxive

Code: Select all

strtotime(); //will work then

Posted: Wed Jul 11, 2007 11:11 am
by aceconcepts
thanks for that, it worked perfectly

Posted: Wed Jul 11, 2007 5:25 pm
by RobertGonzalez
Put it on the database to give it to you the way you want it. In MySQL...

Code: Select all

SELECT DATE_FORMAT(`dateField`, '%W') AS date FROM `myTable`;