--
Linux
1 2 |
# rm -f /etc/localtime # ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime |
--
PHP
1 2 3 4 5 6 7 |
<?php date_default_timezone_set('UTC'); $datetime = new DateTime('2019-9-1 8:00:00'); echo $datetime->format('Y-m-d H:i:s') . "\n"; $la_time = new DateTimeZone('America/Anchorage'); $datetime->setTimezone($la_time); echo $datetime->format('Y-m-d H:i:s'); |
時間加減
1 2 3 4 5 6 7 |
<?php ini_set('date.timezone','UTC'); $datetime = new DateTime('2019-12-1 8:00:00'); echo $datetime->format('Y-m-d H:i:s'); date_sub($datetime, date_interval_create_from_date_string('10 days')); echo $datetime->format('Y-m-d H:i:s'); |
--
MySQL
1 |
# mysql_tzinfo_to_sql /usr/share/zoneinfo/right | mysql -u root mysql -p |
重啟服務
1 |
# systemctl restart mariadb.service |
轉換時區
1 2 |
SELECT CONVERT_TZ(displaytime,'UTC','Asia/Taipei'); SELECT CONVERT_TZ(displaytime,'+00:00','+08:00'); |
--
日光節約
--
--
--
939 total views, 2 views today