I'm updating a legacy Web application to include a php form that once submitted inserts a date time stamp into a table in a MySQL database. The date format in the database is shown as: 2015-05-18 14:34:23.
However, when I display the date in the Web application it comes back as:
1969-12-31 19:33:35. Obviously, the default date of (Dec. 31, 1969) indicates a formatting error... which I'm not sure how to correct.
The sql code is as follows:
$title = mysql_real_escape_string($_POST['tofiles_title']);
$body = mysql_real_escape_string($_POST['tofiles_body']);
$link = "http://example.com/uploads/" . mysql_real_escape_string($_POST['tofiles_link']);
$relation = mysql_real_escape_string($_POST['tofiles_relation']);
$type = mysql_real_escape_string($_POST['tofiles_type']);
$date = date('Y-m-d H:i:s', time());
$ip = $_SERVER['REMOTE_ADDR'];
$post_user = $_SESSION['user_id'];
$sql = "INSERT INTO site_tofiles (tofiles_title, tofiles_body, tofiles_link, tofiles_relation, tofiles_type, tofiles_post_date, tofiles_post_ip, tofiles_post_user) VALUES ";
$sql .= "('$title', '$body', '$link', '$relation', '$type', '$date', '$ip', '$user_id');";
mysql_query($sql);
NOTE: Elsewhere in the legacy Web application post dates are shown in the following format: May 13, 2015, 4:30 pm, and the date in the MySQL database is shown as: 1422475338. I think this is the UNIX code for date if I'm not mistaken.