MySQL now()更改时区 [英] MySQL now() change timezone

查看:1222
本文介绍了MySQL now()更改时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下INSERT语句:

I'm using the following INSERT statement:

INSERT INTO messages SET `to` = '".$to."', `from` = '".$this->userid."', `title` = '".$title."', `message` = '".$message."', `created` = NOW()

但是,它使用我的服务器时间(美国/蒙特利尔).我想要亚洲的时区(Asia/Calcutta)

However, it uses my server time (America/Montreal). I want time zone of Asia (Asia/Calcutta)

使用相同的查询可以吗?

Is this possible with the same query?

推荐答案

您可能想继续使用MySQL中的CONVERT_TZ()函数.它基于操作系统使用的 Olson数据库.

You would want to go ahead and use the CONVERT_TZ() function in MySQL. It's based off the Olson database which your operating system uses.

此处是文档.

这篇关于MySQL now()更改时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆