Skip to content
This repository

Date fields incorrectly translated #799

marcghorayeb opened this Issue · 6 comments

5 participants

Marc Ghorayeb Nate Abele Joel García Verástica Simon JAILLET David Rogers
Marc Ghorayeb

I have a field with a 'date' type. If I input "2013-00-00" as a date, it is translated to "2012-11-30" which is PHP's design of the strtotime function.
However, 2013-00-00 is a valid SQL date, and I need to keep it that way.
I tracked it down to Database.php line 1201.

Same problem goes with fields of type 'timestamp'. If I input a timestamp (an integer), in a timestamp field, the formatter makes it go through the strtotime function which does not understand integers and outputs 0000-00-00 in the SQL update.

Temporary fix: change the date type to a string type in my model schema.

Possible fix:
check for the format of the inputted value before passing it through the formatter? I don't think the value should go through the formatter if the format of the value is already correct.

Nate Abele

Try (object) "2013-00-00".

Marc Ghorayeb

Further testing ... I have a field that's called 'date_creation' and it's default value in maria DB is 'CURRENT_TIMESTAMP'.
When saving a new object to the database, date_creation is translated to '0000-00-00'. The same line is the culprit I think.

Joel García Verástica

The same problem is happening to me, have you found any way to solve it? Thanks :)

jails commented

The workaroud exposed in #776 should work.

David Rogers

I think this is related to #855. Please review.

jails commented

Closed in flavor of #858.

Simon JAILLET jails closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.