I used a variation of Amsul datetime picker found at http://jsfiddle.net/amsul/h2V6w/
HTML code
<h3><label for="call_time">Pick a date & time:</label></h3>
<div id="wrap">
<input type="text" id="call_time"/>
<div id="hidden">
<input type="text" id="date"/>
<input type="text" id="time"/>
</div>
<div id="outlet"></div>
</div>
I have this PHP code to get the date and time from the form above
<?php
require("somedatabasedetails.php"); /*** mysql hostname info ***/
if(isset($_POST['Email']))
{
try
{
// Some other codes here; I used array here since I deleted other
//entries and elements that are working and irrelevant to my question
$call_time = $_POST['call_time'];
$call_time = date('Y-m-d H:i:s', strtotime($call_time));
$que= "INSERT INTO emailsent(call_time) VALUES (:call_time)";
$query2 = $dbh->prepare($que);
$results = $query2->execute(array(
":call_time"=>$call_time,
));
}
catch (PDOException $e)
{
$error = 'Error adding elements to database: ' . $e->getMessage();
echo "Error: " . $error;
exit();
}
exit();
}
?>
On the mysql database, call_time column is formatted as datetime. I tried it also varchar just to test.
My problem is when $call_time is saved on the database it reveals this 1969-12-31 19:00:00. I have read and tried the queries made in these site, but i cant figure out how to get the user entered datetime and save it with the same datetime format to the database.
What part of the code did I do wrong? Or do i need to change timezone?
thanks from a newbie.