lionheart Posted May 31, 2014 Share Posted May 31, 2014 I have a issue about UTC_TIME() and CURTIME(). When I typed this command in windows DOS prompt of mysql client "SELECT CONVERT_TZ(UTC_TIMESTAMP(), 'UTC', 'Asia/Taipei');" , the client show that the time have converted to the Taipei time. But when i entered this following command { page 192, step 5 add new records to the messages table: SELECT INTO messages (parent_id, forum_id, user_id, subject, body, date_entered) VALUES (0, 1, 1, 'Question about normaliztion.' ......}. I see the time of the column - 'date_entered' is not Taipei time in phpMyAdmin. So I typed the following commands: SELECT CURTIME(); SELECT UTCTIMESTAMP(); and they show the two different times. Help This is the snapshot picture. Link to comment Share on other sites More sharing options...
Antonio Conte Posted May 31, 2014 Share Posted May 31, 2014 The conversion is not permanent. You need to apply the same function every time you SELECT the timestamp. Also, it looks like you mix up SELECT statements with INSERT statements here. The general "rule" is: 1. Save all time data in a unified timestamp. (UTC+0) 2. Apply conversion only when you display date info. By doing this, you can also apply user selected time zones, etc, so times can be correct for everyone. 1 Link to comment Share on other sites More sharing options...
lionheart Posted May 31, 2014 Author Share Posted May 31, 2014 Thank you for your helping! Link to comment Share on other sites More sharing options...
Recommended Posts