奇怪的问题日期在PHP中正确打印,但插入数据库为-2017

Finaly managed to get insert to work but now I cant get the date to insert correctly into the DB all the columns in the DB are text Ive tried changing the column names

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else{
  echo "Connected";
  echo "<br>";
}

$Table = mysqli_query($DB, "SELECT * FROM TBL_TimeDate");

while($Row = mysqli_fetch_array($Table)){
    echo "Date: " . $Row['DMY'] . " | Time: " . $Row['Time'];
    echo "<BR>";
}


$Row = mysqli_fetch_array($Table);


$DMY = date("d-m-Y"); 
$Time = time();

echo "Date: " . $DMY . " | Time: " . $Time;


if(!mysqli_query($DB, "INSERT INTO TBL_TimeDate (DMY, Time)
VALUES ($DMY, $Time)"))
{
echo("Error description: " . mysqli_error($DB));

}

?>

output looks like:

Date: -2017 | Time: 1412681153

Date: -2017 | Time: 1412681230

Date: -2017 | Time: 1412681231

Date: 07-10-2014 | Time: 1412681709

Enclose $DMY within quotes.

"INSERT INTO TBL_TimeDate (DMY, Time) VALUES ('$DMY', $Time)"

Note:

For database queries, single quotes should be used for string values. MySQL also expects DATE and DATETIME literal values to be single-quoted as strings.

you can use timestamp function in mysql server instead using date and time function in php.

timestamp not null default current_timestamp

while selecting you can explode the column data (separate the date and time using php )