简体   繁体   English

convert_tz 在 1 小时内更改时间戳

[英]convert_tz change timestamp in 1 hour

I have used convert_tz to insert local date and time into MYSQL table.我使用convert_tz将本地日期和时间插入到 MYSQL 表中。 But there is an issue and it will change time in 1 hour.但是有一个问题,它会在 1 小时后更改时间。 I don't know when it changing and why.我不知道它什么时候改变,为什么改变。

Example:例子:

Priviesly used - CONVERT_TZ(NOW(), 'UTC', '+10:30') to get local time 10:00AM私下使用 - CONVERT_TZ(NOW(), 'UTC', '+10:30')获取当地时间上午 10:00

Now used - CONVERT_TZ(NOW(), 'UTC', '+9:30') to get local time 10:00AM现在使用 - CONVERT_TZ(NOW(), 'UTC', '+9:30')获取当地时间上午 10:00

When I create website I used CONVERT_TZ(NOW(), 'UTC', '+10:30') to get local date and time.当我创建网站时,我使用CONVERT_TZ(NOW(), 'UTC', '+10:30')来获取本地日期和时间。 But from today I need to change all CONVERT_TZ(NOW(), 'UTC', '+10:30') to CONVERT_TZ(NOW(), 'UTC', '+9:30') to get correct local date and time.但是从今天开始,我需要将所有CONVERT_TZ(NOW(), 'UTC', '+10:30')更改为CONVERT_TZ(NOW(), 'UTC', '+9:30')以获得正确的本地日期和时间. Otherwise time is 1 hour added.否则时间增加 1 小时。

How to solve this issue?如何解决这个问题?

UPDATE: I am using inmotion hosting.更新:我正在使用 inmotion 托管。

UPDATE 2:更新 2:

I am using to get date and time following code in PHP.我正在使用 PHP 中的代码获取日期和时间。

$lastdatepost = new DateTime("now", new DateTimeZone('Asia/Colombo'));
$lastdatepost = $lastdatepost->format('Y-m-d H:i:s');

This will effect with above CONVERT_TZ(NOW(), 'UTC', '+10:30') SQL code and both date and time different which is 1 hour added.这将影响上面的CONVERT_TZ(NOW(), 'UTC', '+10:30') SQL 代码和日期和时间不同,即增加 1 小时。 Then give error.然后报错。

UTC offsets change over the course of the year in most places around the globe due to Daylight Saving Time aka Summer Time.由于夏令时,全球大部分地区的 UTC 偏移量在一年中发生变化。 India isn't one of those places, but the US went on DST today, so the timing is suspicious.印度不是这些地方之一,但美国今天进行了夏令时,所以时间很可疑。

What is your application?你的应用是什么? If PHP and MySQL have different ideas of what time it is, that implies to me that one of them must be storing local time and have an incorrect offset to UTC.如果 PHP 和 MySQL 对现在的时间有不同的想法,这对我来说意味着其中一个必须存储本地时间并且与 UTC 的偏移量不正确。 Does your application perhaps run on Windows?您的应用程序是否可能在 Windows 上运行?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM