SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    not displaying right date

    Hi guys

    heres my code

    PHP Code:
    $title13date("jS F y"strtotime($row_articles['startdate'])); 
    problem is its showing todays date and not the one posted in the database

    many thanks.

  2. #2
    SitePoint Enthusiast shn's Avatar
    Join Date
    Jan 2006
    Location
    Munich DE
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What value does $row_articles['startdate'] contain and what does strtotime() return?
    Patrick

  3. #3
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you use query to get value of right date

    PHP Code:
    $query="select *, date_format(startdate,'%D %b %Y') as MyDate from table_name";

    // now $row_articles['MyDate'] will give the correct date 
    Barbara

  4. #4
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont understand?

    how does that tie in with

    $title13= date("jS F y", strtotime($row_articles['startdate']));

  5. #5
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As per my understanding I think your 'startdate' field of table must contain date.rt?

    you have given "$row_articles['startdate']" means you are using select query to retrieve the date.So I think you can get the date in format like (5th May 07).
    To get the date in this format from database use the following query

    PHP Code:
    $query="select *, date_format(startdate,'%D %b %Y') as MyDate from table_name";
    $result=@mysql_query($query);
    if(@
    mysql_num_rows($result) > 0)
    {
    while(
    $row_articals=@mysql_fetch_array($result))
    {
    echo 
    $row_articals['MyDate'] . "<br>";
    }
    }

    // now $row_articles['MyDate'] will give the correct date 
    Barbara


Bookmarks

Posting Permissions

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