Jump to content

[SOLVED] Date Displaying as Jan 1, 1970


ShoeLace1291

Recommended Posts

The table row in PMA says the date for that row is 2005-05-24, but the page is displaying it as Jan 1, 1970.  This is my code:

 

$news = mysql_query("SELECT newsID,posterID,headline,message,datetime FROM news ORDER BY newsID DESC LIMIT 5") or die("Unable to fetch news articles.");

$articles = mysql_num_rows($news);

if($articles != 0){

            while($fetch=mysql_fetch_array($news)){
                     $posterid=$fetch["posterID"];
                     $headline=$fetch["headline"];
                     $message=$fetch["message"];
                     $datetime=$fetch["datetime"];
                     $datetime=date('M j, o',$datetime);

              

                     $poster = mysql_query("SELECT username FROM users WHERE uid = $posterid") or die("Unable to find news author.");

             $newsinfo=mysql_fetch_array($poster);

                  $author=$newsinfo["username"];

                     echo "<b>$headline</b><br>$message<br><div align='right'>Posted by $author on $datetime</div>";

} 

} else {

       echo "There no news articles to display at this time.";

}

Link to comment
Share on other sites

Got it.  Used a much easier method than that, Gmunky.

 

I was wondering... How do I set the datetime row with a mysql_query? 

 

something like this:

 

mysql_query("INSERT INTO news(posterID,headline,message,datetime)
             values('$posterID', '$headline', '$message', '$datetime');

 

What value would $datetime be?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.