Datetime error on server, but OK on local dev machine?

I know that there have been a number of posts about datetime issues but I can’t find the answer to this issue.

I am simply trying to insert a value of NULL.

I am using the Wappler Date Picker.

The insert query has this

image

Devtools shows this in both instances under XHR/Headers

data_to: 0000-00-00 00:00:00

But I get this error on the Server only

message: "SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '-0001-11-30 00:00:00' for column `dg_db`.`tbl_menu_list`.`data_to` at row 1"

Everything did work OK until recently. The only thing I do know is that the hosting company did upgrade some programs on the server.

Current set-up : SPA Pages, Windows 10, MySQL, PHP
Wappler Version : 3.9.7
Operating System : Windows 10 Pro 64bit
Server Model: PHP
Database Type: MySQL

From mysql documentation:

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD hh:mm:ss ’ format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' .

Probably mysql on the server is set to strict mode and don’t allow this, so check this on your server.

UPDATE: It took me ages to resolve this issue and at the end of the day it was my error. The form and query was an INSERT and the form should have been blank (no values) but for some reason I had been populating with zero data (0000-00-00 00:00:00) which wasn’t liked. As soon as I removed the pre-populated data, the form and insert worked like a charm.

Moral of the story: With any errors, always go back and look at the basics first and then work your way up.

1 Like