当前位置: 动力学知识库 > 问答 > 编程问答 >

mysql - How to create trigger for insert UTC date&time automatically while insert record.?

问题描述:

I have mysql trigger for specific table, which insert date&time record while inserting any new record in table automatically. For this I used NOW() mysql function which return current system date and time. But in my requirement, need to store date and time in UTC format. For this I applied UTC_TIMESTSAMP(), but still it insert current system time.

following is my trigger.

CREATE DEFINER=`root`@`%` TRIGGER `PawPhrazerProduct`.`caregiver_info_BEFORE_INSERT` BEFORE INSERT ON `caregiver_info` FOR EACH ROW BEGIN IF NEW.createdDateAndTime = '0000-00-00 00:00:00' THEN SET NEW.createdDateAndTime = utc_timestamp(); END IF; END

Following are the column structure.

Column Name : createdDateAndTime

Data Types : TIMESTAMP Not Null Default '0000-00-00 00:00:00'

分享给朋友:
您可能感兴趣的文章:
随机阅读: