I am struggling to get the correct date entered into my database when someone signs up on my site. I am able to get a date entered into my database using the following code:
$insertdate = date('m-d-Y', strtotime($_POST['Date']));
$sql = $con->query("INSERT INTO BD (sfm_form_submision_date, FirstName, LastName, Email, UserName, Password) Values( '{$insertdate}', '{$FName}', '{$LName}', '{$Email}', '{$UName}','{$PW}')");
header('Location: login.php');
My problem is that the date in my database reads:
12-31-1969
This is driving me crazy as the date on my computer is 6/5/2016
.
Any suggestions? Thanks!
My code for processing is:
$sql = $con->query("INSERT INTO BD (_sfm_form_submision_date_, FirstName, LastName, Email, UserName, Password) Values( '{$insertdate}', '{$FName}', '{$LName}', '{$Email}', '{$UName}','{$PW}')");
header('Location: login.php');
I fear I am overthinking this. All I need is a simple way to enter the current date when the submit button in pressed.
I was able to get the current date by removing {$insertdate}
an replacing it with CURDATE()
in my code as specified below:
$sql = $con->query("INSERT INTO BD (_sfm_form_submision_date_, FirstName, LastName, Email, UserName, Password) Values( '{$insertdate}', '{$FName}', '{$LName}', '{$Email}', '{$UName}','{$PW}')");
header('Location: login.php');