Forum Moderators: coopster

Message Too Old, No Replies

Formatting the way a date displays.

         

michlcamp

2:25 am on Feb 19, 2006 (gmt 0)

10+ Year Member



I have a form field ('date') that stores the date in a table as : '02-19-2006'

(These are future calendar dates that make up an "Upcoming Events" page...)

I need to display it on the output page as: 'Saturday February 19, 2006'

but still want to sort the query output using 'ORDER BY 'date'

how to?

Thanks in advance.
m

IamStang

3:52 am on Feb 19, 2006 (gmt 0)

10+ Year Member



Hello michlcamp,

Have a look at this:
[php.net...]

Specifically the entry by Jay J on 11-Nov-2005 09:13. This may be what you are looking for. I played with it for a few minutes and it seems to work well.

Hope it helps!
IamStang

BarryStCyr

3:53 am on Feb 19, 2006 (gmt 0)

10+ Year Member



'Saturday February 19, 2006'

When you output your table use the php command date as follows:

print date("l F j, Y",mktime(0,0,0,substr($date,0,2),substr($date,3,2),substr($date,6,4));

The date format is:
l = (Lower case L) full day name
F = full month name
j = (Lower case J) day of month without leading zero
Y = 4 digit year.

Hope this helps

dreamcatcher

8:20 am on Feb 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would store the date as a DATE field, ie: YYYY-MM-DD, then use DATE_FORMAT in the SQL query.

dc

omoutop

7:42 am on Feb 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i prefer storing date/time values as integers (unix time)... that way anyone can use them easily, no matter what date format they use