Forum Moderators: coopster

Message Too Old, No Replies

date formatting

         

dave1236

1:36 am on Aug 31, 2009 (gmt 0)

10+ Year Member



All:

I ma trying to format some dates. In my DB, I store a date in this format: 2009-08-30 (field is called 'entry')

I want to display it as "August 30, 2009"

I tried the following, but this does not work:

$displaydate = $entry ("F d, Y");

Thoughts?

Thanks in advance!

dave1236

1:37 am on Aug 31, 2009 (gmt 0)

10+ Year Member



I hit send too soon - I also was wondering how I could set the time zone to EST?

Thanks again

Pico_Train

6:50 am on Aug 31, 2009 (gmt 0)

10+ Year Member



select DATE_FORMAT (date_field, "%F %d, %Y") as new_date ...

This should spit out your new date in the format you desire as $va['new_date'];

andrewsmd

6:07 pm on Aug 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know if you can do this now, but I always store dates in a unix timestamp when I can. It makes them easier to work with when you need to select entries based on time specifications such as within 5 to 8 pm or something like that. Otherwise try the mktime function
mktime(hour,minute,second,month,day,year,is_dst)
in your case $displaydate = date("F d, Y", mktime(0,0,0,8,30,2009));