Jump to content

Recommended Posts

Hi, I'm trying to display the date an article was published. They are saved to a database, with the date stored as a 'timestamp' under the column: 'article_timestamp' but I want the date displayed in a readable format such as 'DD-MM-YY 00:00:00' I have created the code so far which calls the article titles, and put them in a list, but am having trouble with the dates.

 

This is the page so far: http://www.f1times.co.uk/archive.php

 

<?php
$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("f1times_articles", $con);

$result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 21,35");

echo "<table border='0'>
<tr>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
    $url = $row['article_url'] . "-" . $row['article_id'] . ".html";
    echo "<tr>";
    echo "<td><h5><a href='$url'>".stripslashes($row['article_title'])."</h5></a></td>";
    }

mysql_close($con);
?>	

 

I really have no clue where to go from here, everything I have tried hasn't worked, any help is greatly appreciated. Thanks in advance.

<?php
$con = mysql_connect("localhost","xxxx","xxxx");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("f1times_articles", $con);

$result = mysql_query("SELECT * FROM n2s_article ORDER BY article_id DESC LIMIT 21,35");

echo "<table border='0'>
<tr>
<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
    $url = $row['article_url'] . "-" . $row['article_id'] . ".html";
    echo "<tr>";
    echo "<td><h5><a href='$url'>".stripslashes($row['article_title'])."</h5></a></td>";
echo "<td>".date('d-m-Y g:i:s', $row['article_timestamp'])."</td>";
echo "</tr>";
    }

mysql_close($con);
?>

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.