PHP MYSQL日期格式输出为零

This variable gets inserted into my mysql database:

$n_date = date('d-m-Y');

and in the database i always see this:

0000-00-00 00:00:00

What am i doing wrong?

Because your format is wrong. MySQL expects the date to be in YYYY-MM-DD format. So:

$n_date = date('d-m-Y');

should be

$n_date = date('Y-m-d');

Or, for completeness:

$n_date = date('Y-m-d H:i:s');

You will need to format dates for insert into MySQL as yyyy-mm-dd.

$n_date = date('YYYY-mm-dd hh:ii:ss');

Insert that way.

Your format is incorrect. Why not just INSERT NOW()?

INSERT INTO tbl (dateCol) VALUES (NOW())