#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    OKC, OK USA
    Posts
    2
    Rep Power
    0
    I have been reading through the posts here and found some great information, but for some reason cannot get this date function to print correctly.

    I have dates stored in MySQL in the YYYY-MM-DD format and I am placing them in a string $EventStartDate in my code. I am trying to print the string in a more attractive format. Instead of 2000-09-06 I would like Wed Sep 6th, 2000.

    I have found how to print the date in this format using date(), but when I use this on the string I get Weds Dec 31st, 1969. What am I doing wrong? (I know the dates are stioring correctly in the DB, I have checked that)

    Here is how I am doing it:
    //$EventStartDate is pulled from db

    $StartDate=date("D M jS, Y",$EventStartDate) ;
    print "<td>$StartDate</td>" ;
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    date() is a PHP function for formating a unix timestamp. It has nothing to do with mysql date/time datatypes. Look in the mysql manual under date_format() for the mysql function to format the date the way you want.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Helden,Limburg,The Netherlands
    Posts
    33
    Rep Power
    15
    As an alternative you can put the UNIX-timestamp(returned by the function time() in PHP) in the database (not in a date-field but in a unsigned INT field) and then you can easily retreive the timestamp and use the date() function to format it.

    Good luck,
    Ramon.

    ------------------
    Ramon Litjens
    Boradoli Web Design
    (www.boradoli.nl)
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    North York, Ontario, Canada
    Posts
    1
    Rep Power
    0
    See DBrown's post titled "Formatting a queried date datatype...how?" from Dec 31,1999 and rodk's response.

Similar Threads

  1. using string functions to take out date
    By pumpkin head in forum Visual Basic Programming
    Replies: 7
    Last Post: November 9th, 2004, 09:50 AM
  2. array explode ( string separator, string string [, int limit])
    By beemee_freeserv in forum HTML Programming
    Replies: 4
    Last Post: February 5th, 2004, 10:56 AM
  3. mgetty+sendfax on RH9
    By ayrin in forum Linux Help
    Replies: 0
    Last Post: January 31st, 2004, 02:11 AM
  4. Unix : String to date conversion error?
    By tzeyik in forum Java Help
    Replies: 2
    Last Post: January 26th, 2004, 07:11 AM
  5. comparing 2 string date fields to a month/year
    By tlgates in forum MySQL Help
    Replies: 4
    Last Post: December 19th, 2003, 01:25 PM

IMN logo majestic logo threadwatch logo seochat tools logo