Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Location
    Nottingham, UK
    Posts
    37

    Question Unanswered: date formatting w mySQL

    Hi,

    I'm trying to format a date, see http://www.claustrophonic.com/photos...eyPhrase=jason

    the date() function doesn't seem to be working for me. In mysql, the dates are formatted thusly: yyyy-mm-dd

    The first date displayed is doing this

    if (substr($row["imageDate"], -2, 2) != "00")
    $theDay = date('d', $row["imageDate"]);
    else
    $theDay = "";
    $theMonth = date('M', $row["imageDate"]);
    $theYear = substr($row["imageDate"], 0, 4);
    $theDate = $theDay;
    $theDate .= " ";
    $theDate .= $theMonth;
    $theDate .= " ";
    $theDate .= $theYear;
    [and then displaying $theDate]

    the second one is just showing the value straight from the database.

    $row["imageDate"]

    and the last one uses the date function on the value in the database:

    $theDate2 = date('m/d/Y', $row["imageDate"]);
    Last edited by skinnywhitegeek; 07-20-03 at 21:50.

  2. #2
    Join Date
    Jan 2002
    Location
    Nottingham, UK
    Posts
    37
    Never mind, I figured out I needed to use the strtotime() function. e.g.

    $theDate2 = date('m/d/Y', strtotime($row["imageDate"]));

    still learning the ins and outs of php syntax.

  3. #3
    Join Date
    Jul 2003
    Location
    New Zealand
    Posts
    9
    cool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •