, , , .
I started thinking how I can make formatting possible. I have an idea. How about running this? I mean adding a column with a type char, and then updating that column with a MySQL trigger. And it worked! I did some research related to triggers, and finally came up with these queries:
CREATE TRIGGER timestampper BEFORE INSERT ON table
FOR EACH
ROW SET NEW.timestamp = DATE_FORMAT(NOW(), '%d/%m/%Y');
CREATE TRIGGER timestampper2 BEFORE UPDATE ON table
FOR EACH
ROW SET NEW.timestamp = DATE_FORMAT(NOW(), '%d/%m/%Y');
You cannot use TIMESTAMPeither DATEas a column type because they have their own format and are automatically updated.
So, here is your alternate timestamp or alternative to dates! Hope this helps, at least I'm glad I did it.
source
share