php - php如何设置时区,如(utc + 1 utc-5)而不是(欧洲/阿姆斯特丹......)
问题描述
我想显示世界上所有国家/地区的日期和时间问题是 40 多个国家/地区使用 utc+1 并且很难为每个国家/地区指定特定时区示例:伦敦、摩洛哥和尼日尔具有相同的日期和时间
london => date_default_timezone_set('Europe/London');
morocco => date_default_timezone_set('Africa/Casablanca');
niger => date_default_timezone_set('Africa/Lagos');
我的第一个问题是为什么 php 不支持:
date_default_timezone_set('utc+1')
date_default_timezone_set('utc+2')
以及如何为所有国家/地区定义一个时区,使用 utc+5 或 utc+2
解决方案
你看过时区列表吗?格林尼治标准时间的会做你想做的
https://www.php.net/manual/en/timezones.others.php
Etc/GMT+1 Etc/GMT+10 Etc/GMT+11 Etc/GMT+12
Etc/GMT+2 Etc/GMT+3 Etc/GMT+4 Etc/GMT+5
Etc/GMT+6 Etc/GMT+7 Etc/GMT+8 Etc/GMT+9
Etc/GMT-0 Etc/GMT-1 Etc/GMT-10 Etc/GMT-11
Etc/GMT-12 Etc/GMT-13 Etc/GMT-14 Etc/GMT-2
Etc/GMT-3 Etc/GMT-4 Etc/GMT-5 Etc/GMT-6
Etc/GMT-7 Etc/GMT-8 Etc/GMT-9 Etc/GMT0
推荐阅读
- python - 删除带有“NoneType”和字符串的行:只保留数值
- google-cloud-platform - 边缘设备的 Google 对象检测模型生命周期
- docker - Gitlab Runner - Docker 服务致命错误
- python - 为什么我的 django 模型数据不显示在 html 中
- visual-c++ - 与其他对话框结合的非模态、自动关闭对话框的问题
- wpf - WPF 控制工具提示弹出窗口
- flutter - 如何从中心为半径的容器开槽
- xpages - NotesXspDocument.save() 不允许访问或修改文件“/local/notesdata/xsppers”
- colors - 如何在lua中正确地将hsl颜色转换为rgb颜色?
- php - 适用于 PHP 的 Microsoft Azure SDK 出现错误:未定义类型“MicrosoftAzure\Storage\Blob\BlobRestProxy”