Google Colab中的不同时区 [英] Different timezone in Google Colab
问题描述
问题:为什么Colab中的时区与本地时区不同?
Question: Why does the timezone in Colab different from local timezone?
背景:我住在美国.但是Colab时间(我指定了美国时区)与本地时间之间有五个小时的差异.
Background:: I'm living in US. But the there is a five hours difference between the Colab time (I specify the US timezone) and local time.
代码:
!rm /etc/localtime
!ln -s /usr/share/zoneinfo/US /etc/localtime # the time should be around 11:20
!date
结果:世界标准时间2019年8月7日星期三16:20:40
Results: Wed Aug 7 16:20:40 UTC 2019
推荐答案
您可以分两个步骤更改时区:
You can change the timezone in two steps:
第1步:在层次结构中找到您的时区名称
Step 1: Find the name of your timezone in the hierarchy
!ls -al /usr/share/zoneinfo/
对于美国,您将通过以下方式再遍历时区树:
For US, you would then traverse the timezone tree one more level by:
!ls -al /usr/share/zoneinfo/US
这给你
drwxr-xr-x 2 root root 4096 Dec 22 02:14 .
drwxr-xr-x 21 root root 4096 Dec 22 02:14 ..
lrwxrwxrwx 1 root root 20 Oct 23 06:18 Alaska -> ../America/Anchorage
lrwxrwxrwx 1 root root 15 Oct 23 06:18 Aleutian -> ../America/Adak
lrwxrwxrwx 1 root root 18 Oct 23 06:18 Arizona -> ../America/Phoenix
lrwxrwxrwx 1 root root 18 Oct 23 06:18 Central -> ../America/Chicago
lrwxrwxrwx 1 root root 13 Oct 23 06:18 Eastern -> ../posixrules
lrwxrwxrwx 1 root root 21 Oct 23 06:18 East-Indiana -> ../America/Fort_Wayne
lrwxrwxrwx 1 root root 19 Oct 23 06:18 Hawaii -> ../Pacific/Honolulu
lrwxrwxrwx 1 root root 18 Oct 23 06:18 Indiana-Starke -> ../America/Knox_IN
lrwxrwxrwx 1 root root 18 Oct 23 06:18 Michigan -> ../America/Detroit
lrwxrwxrwx 1 root root 9 Oct 23 06:18 Mountain -> ../Navajo
lrwxrwxrwx 1 root root 22 Oct 23 06:18 Pacific -> ../America/Los_Angeles
lrwxrwxrwx 1 root root 17 Oct 23 06:18 Samoa -> ../Pacific/Midway
第2步:
使用在步骤1中获得的正确参考设置时区.如果您住过在芝加哥,正确的参考是: Central
.您可以通过以下方式更改Google Colabo时区:
Set the time zone with the correct reference obtained in Step 1.
If you lived e.g. in Chicago, the correct reference would be: Central
.
You can change the Google Colabo timezone by:
!rm /etc/localtime
!ln -s /usr/share/zoneinfo/US/Central /etc/localtime
!date
请记住正确的参考是在两个层次的层次结构中,其中首先包含区域( US/Central
),而不仅仅是时区 Central
.
Remember the correct reference is in a hierarchy of two levels containing the region first (US/Central
), not just the time zone Central
.
这篇关于Google Colab中的不同时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!