I have a php form that once submitted is supposed to insert at date and time for which the form was submitted. The format I'm looking for is: May 13, 2015, 4:30 pm
But instead I'm getting: 1969-12-31 19:00:05
. Obviously, with the date retrieved from the record there is a formatting error (Dec. 31, 1969).
On the php submission form the hidden field code is:
<input type="hidden" name="tofiles_post_date" value="<?php echo date('m/d/Y F j, Y, g:i a', time()); ?>">
On the php confirmation page where the date is inserted into the mysql database is:
$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 = mysql_real_escape_string($_POST['tofiles_post_date']);
$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);
Obviously, I'm missing something here.