2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CircleCIでタイムゾーン変更

Posted at

Why

タイムゾーンがサーバとDBで違う場合にCircleCIでのテスト環境を揃えたい

What

  • サーバがAsia/Tokyo
  • DBがUTC

AWSのEC2/RDSを使ってるとよくある構成(RDSも最近はTZ設定できるけど)

How

circle.yml
machine:
  timezone:
    Asia/Tokyo
database:
  pre:
      - mysql -e "system date; show variables like '%time_zone%'; select now();"
      - mysql -e "set GLOBAL time_zone = '+00:00';"
      - mysql -e "system date; show variables like '%time_zone%'; select now();"

Result

$ mysql -e "system date; show variables like '%time_zone%'; select now();"
Tue Jan 24 20:32:47 JST 2017
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | JST    |
| time_zone        | SYSTEM |
+------------------+--------+
+---------------------+
| now()               |
+---------------------+
| 2017-01-24 20:32:47 |
+---------------------+

$ mysql -e "set GLOBAL time_zone = '+00:00';"

$ mysql -e "system date; show variables like '%time_zone%'; select now();"
Tue Jan 24 20:32:51 JST 2017
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | JST    |
| time_zone        | +00:00 |
+------------------+--------+
+---------------------+
| now()               |
+---------------------+
| 2017-01-24 11:32:51 |
+---------------------+
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?