PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Wed Jul 11, 2007 10:00 am
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:
but this displays the same day for each in the loop.
Zoxive
Forum Regular
Posts: 974 Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan
Post
by Zoxive » Wed Jul 11, 2007 10:38 am
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
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Wed Jul 11, 2007 10:41 am
$sessionDate is currently formatted as date (0000-00-00)
Zoxive
Forum Regular
Posts: 974 Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan
Post
by Zoxive » Wed Jul 11, 2007 11:08 am
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Wed Jul 11, 2007 11:11 am
thanks for that, it worked perfectly
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed Jul 11, 2007 5:25 pm
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`;