Erratic DateTimePicker field updating behavior

Hi! I'm having a strange issue with the DateTimePicker field. Whenever I edit the form it keeps altering my date, even when I make no changes to the form or change other fields. It keeps getting pushed towards the current time. The fields in my form are as follows. Only the started_at field is affected.
DateTimePicker::make('started_at')
->withoutSeconds()
->required()
->label('Starts at')
->hint('Enter a UTC time'),

DateTimePicker::make('ended_at')
->withoutSeconds()
->required()
->after('started_at')
->label('Ends at')
->hint('Enter a UTC time'),
DateTimePicker::make('started_at')
->withoutSeconds()
->required()
->label('Starts at')
->hint('Enter a UTC time'),

DateTimePicker::make('ended_at')
->withoutSeconds()
->required()
->after('started_at')
->label('Ends at')
->hint('Enter a UTC time'),
I've got the spatie/laravel-activitylog package installed and it's logging changes like these. In none of these cases did I alter the started_at value in the form when I submitted the update.
{"attributes":{"started_at":"2023-04-12T15:24:00.000000Z"},"old":{"started_at":"2023-04-30T15:24:59.000000Z"}}

{"attributes":{"name":"the test event","started_at":"2023-04-30T15:28:57.000000Z"},"old":{"name":"test event","started_at":"2023-04-12T15:24:00.000000Z"}}

{"attributes":{"started_at":"2023-04-30T15:28:00.000000Z"},"old":{"started_at":"2023-04-30T15:28:57.000000Z"}}

{"attributes":{"name":"the testing event","started_at":"2023-04-30T15:35:57.000000Z"},"old":{"name":"the test event","started_at":"2023-04-30T15:28:00.000000Z"}}

{"attributes":{"state":"published","started_at":"2023-04-30T16:03:05.000000Z"},"old":{"state":"hidden","started_at":"2023-04-12T05:00:00.000000Z"}}
{"attributes":{"started_at":"2023-04-12T15:24:00.000000Z"},"old":{"started_at":"2023-04-30T15:24:59.000000Z"}}

{"attributes":{"name":"the test event","started_at":"2023-04-30T15:28:57.000000Z"},"old":{"name":"test event","started_at":"2023-04-12T15:24:00.000000Z"}}

{"attributes":{"started_at":"2023-04-30T15:28:00.000000Z"},"old":{"started_at":"2023-04-30T15:28:57.000000Z"}}

{"attributes":{"name":"the testing event","started_at":"2023-04-30T15:35:57.000000Z"},"old":{"name":"the test event","started_at":"2023-04-30T15:28:00.000000Z"}}

{"attributes":{"state":"published","started_at":"2023-04-30T16:03:05.000000Z"},"old":{"state":"hidden","started_at":"2023-04-12T05:00:00.000000Z"}}
1 Reply
Lord of Darkness
Lord of DarknessOP2y ago
Think I figured this out - it's caused by started_at defaulting to the current time in the database.

Did you find this page helpful?