Jump to content
Larry Ullman's Book Forums

Recommended Posts

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 :mellow:

This is the snapshot picture.

question_timestamp.jpg

Link to comment
Share on other sites

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.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...