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?
verify your timezone with query
SELECT * FROM pg_timezone_names
now add phpstorm.vmoptions the config off timezone
-Duser.timezone=posix/America/Sao_Paulo
Apply changes, disconect, synchronize and verify whithselect now()
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With