是否可以为PHPStorm中的数据库数据源指定时区? [英] Is it possible to specify time zone for DB data source in PHPStorm?

查看:997
本文介绍了是否可以为PHPStorm中的数据库数据源指定时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 UTC 在我的PostgreSQL和时区设置SELECT NOW()显示我正确的日期 psql 控制台。



我使用PHPStorm进行开发及其数据库控制台访问我的数据库,但它使用不同的时区(Europe / Moscow,这是我的Mac的时区)和 SELECT NOW()显示我在此时区的时间(顺便说一句,日期是错误的,因为欧洲/莫斯科时区最近更改其偏移为 +3 来自 +4 )。



发现任何信息,如何告诉PHPStorm使用在 postgresql.conf 中配置的时区,而不是系统的时区。可能吗?

解决方案

好吧,我找到了一个解决方案,但它会影响IDE中每个特定于时间的行为,例如控制台日志将以UTC显示datetime。



这个想法是将时区传递给VM选项。为此,我们需要修改文件并重新启动IDE。



对于Mac OS X,最新版本的PHPStorm:

  cp /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions〜/ Library / Preferences / PhpStorm2016.1 / 
pre>

然后将 -Duser.timezone = UTC 添加到文件,以使其看起来像这样: / p>

  -Xms128m 
-Xmx750m
-XX:MaxPermSize = 350m
-XX:ReservedCodeCacheSize = 240m
-XX:+ UseCompressedOops
-Duser.timezone = UTC


I have UTC time zone set in my PostgreSQL and SELECT NOW() shows me the right date in psql console.

I use PHPStorm for development and its database console for accessing my database, but it uses different time zone (Europe/Moscow, which is the time zone of my Mac), and SELECT NOW() shows me the time in this time zone (and by the way, the date is wrong, because the Europe/Moscow time zone recently changed its offset to +3 from +4).

I have not found any information on how to tell PHPStorm to use the time zone configured in postgresql.conf instead of system's time zone. Is it possible?

解决方案

Well, I've found a solution, but it will affect every time-specific behavior in IDE, e.g. console logs will show datetime in UTC.

The idea is to pass a timezone to VM options. For that we need to modify a file and restart IDE.

For Mac OS X for the latest version of PHPStorm:

cp /Applications/PhpStorm.app/Contents/bin/phpstorm.vmoptions ~/Library/Preferences/PhpStorm2016.1/

Then add -Duser.timezone=UTC to the file, so that it looks something like that:

-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-Duser.timezone=UTC

这篇关于是否可以为PHPStorm中的数据库数据源指定时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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