How to let MySQL NOW() function return the user time

85 views Asked by At

I ran into a very tricky MySQL issue.. Our DB is using type DateTime for the updated_at column, and now is too late to change it back to TimeStamp. I'm thus trying to add a trigger to update this updated_at column on table changing. The following is what I did:

CREATE TRIGGER foo_schema.bar_datetime_trigger BEFORE UPDATE ON foo_schema.bar FOR EACH ROW set NEW.updated_at = NOW();

The NOW() function here returns the DB time; however, what I actually want is to set the udpated_at as the user time (Meaning the time of the user who made changes to table bar). Is it possible to handle this in MySQL?

0

There are 0 answers