I have two applications using the same postgres DB. A laravel application and a rails application. The current data in the DB is in Y-m-d H:i:s
format but whenever rails adds a records, the format is Y-m-d H:i:s.u
which includes milliseconds.
This causes the following error on the laravel side if the created_at date is ever references in laravel InvalidArgumentException Trailing data
...
Laravel models can mutate their date format, so I can include make it conform to Y-m-d H:i:s.u
then I would need to update all the records to have the miliseconds in the created_at date ( and any other timestamps). Unfortunatly when I specify the format to be Y-m-d H:i:s
for the laravel model, it will not ignore the decimals. This is why I'm now looking for ways to default rails to save in the Y-m-d H:i:s
format, instead of including the miliseconds. Then both the Rails and Laravel applications would be using the same format and there wouldn't be any conflict.
I know I can go into the DB and change the column type to timestamp(0) which truncates the decimals, but I would perfer to change the format that the frameworks are saving, rather then change what the DB will accept.
Both Y-m-d H:i:s
and Y-m-d H:i:s.u
are valid timestamps... If I could get Rails to use the Y-m-d H:i:s
format or have Laravel ignore the .u when looking at timestamps to prevent the trailing data error, I would be in the clear.
Is there a way to change the default format that rails saves timestamps to the DB?
Is a way to have Larave Carbon ignore the decimal portion of a timestamp in the Y-m-d H:i:s.u
format?
Thanks