Closed nenadmilosavljevic closed 6 years ago
You could do something like:
public static function events(EventEmitter $emitter)
{
$emitter->on("beforeUpdate", function (EntityInterface $entity, MapperInterface $mapper) {
$entity->updated_at = new \DateTime();
});
}
I think that @tuupola's answer is the preferred way, but if you want to use timestamps (like me) you can define a custom type.
Hello, what would be the best way to save current timestamp when an entity is updated? Ideally, if triggers are supported I'd like to define DateTime property which would be updated with current DateTime on each ON_UPDATE Otherwise, how can I define on_update_current_timestamp for a timestamp field in an model class (which extends entity)?