I built a quick date time test page. The coding is below followed by its results. I'm entering the raw timestamp into table time because i want to be able to manipulate it once i show it (say if i want to show time and date using the same timestamp). Let me know what i'm doing wrong. Thanks
datetest.php
include 'config2.php';
$dbname = 'time';
$tablename = 'time';
include 'opendb.php';
$name=$_POST['name'];
$date= date("g:ia");
$timestamp=time();
mysql_query ("INSERT INTO $tablename (timestamp,name)
VALUES ('$timestamp','$name')");
$res = mysql_query("SELECT timestamp, name FROM time ORDER BY timestamp DESC;");
while ( $row = mysql_fetch_array($res) ) {
$timestamp = strtotime($row["timestamp"]);
echo $row["name"] . "<br />";
echo $row["timestamp"] . "<br />";
echo date("g:i a F j, Y ", $timestamp) . "<br /><br />";
}
Here are the results. Why does it keep showing me the the same date?
john
1311821078
12:00 am January 1, 1970
toni
1311820715
12:00 am January 1, 1970
rafmon
1311820431
12:00 am January 1, 1970