I am trying to insert date& time but error shows
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect time value: '1505572990' for column 'vdate' at row 1
Please help me out by editing the code and getting solved the problem
My codes:
class.php
<?php
require_once 'db.php';
require_once 'lang.php';
class USER
{
private $conn;
public function __construct()
{
$database = new Database();
$db = $database->dbConnection();
$this->conn = $db;
}
public function runQuery($sql)
{
$stmt = $this->conn->prepare($sql);
return $stmt;
}
public function lasdID()
{
$stmt = $this->conn->lastInsertId();
return $stmt;
}
public function register($uname)
{
try
{
$stmt = $this->conn->prepare("INSERT INTO validation(vdate)
VALUES(:user_name)");
$stmt->bindparam(":user_name",$uname);
$stmt->execute();
return $stmt;
}
catch(PDOException $ex)
{
echo $ex->getMessage();
}
}
}
index.php
<?php
session_start();
require_once 'class.php';
$reg_user = new USER();
if(isset($_POST['btn-signup']))
{
$uname = time();
if($reg_user->register($uname))
{
$msg = "
<div class='alert alert-success'>
<button class='close' data-dismiss='alert'>×</button>
<strong>Success!</strong> To activate your account, you need to verify your email. We have sent a verify link at <strong></strong>.
</div>
";
}
else
{
echo "sorry , Query could no execute...";
}
}
?>
The only thing I want that when a user clicks a button it should insert date&time
in MySQL.
I tried the above code but it showed me error
SQLSTATE[22007]: Invalid DateTime format: 1292 Incorrect time value: '1505572990' for column 'vdate' at row 1
Please help me out by editing the code and getting solved the problem