Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bradbforbes's avatar

Mutated date columns being set to current timestamp

I have an Eloquent model with an attribute included in the $dates array. For some reason, I’m having a problem with the value of this column sometimes being persisted as the current timestamp when the model is saved, so that it ends up matching 'updated_at' exactly. I’ve seen this happen in two different models in two different Laravel apps I maintain recently, and in both cases I can’t track down the cause of this for the life of me. Neither applications have a usage that would ever explicitly set this attribute value to the current time, so I'm wondering if there's something about how Eloquent mutates dates that I just don't understand. Does anyone know what may be causing this? Thanks!

0 likes
1 reply
DarkRoast's avatar

What does your migration SQL output look like? Is there anything like ON UPDATE CURRENT_TIMESTAMP on that column?

Please or to participate in this conversation.