Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To run my web app, I need to set my timezone to UTC on my MacBook. I can do this temporarily by opening a Konsole and entering

sudo ln -sf /usr/share/zoneinfo/UTC /etc/localtime

However, my timezone returns to normal when I restart my machine!

Any advice?

Edit : The response to this question by 'Celada' implies that I can just make my Server UTC. I am using Apache Tomcat 7. Adding to Celada's response, how can I make it UTC?

Update - 3rd April : Following Celada's response, I have tried adding SetEnv TZ UTC at the top of This didn't seem to make a difference. After some research, I tried adding export JAVA_OPTS="-Duser.timezone=UTC" to, but this too had no effect. Am I adding the correct command to the correct file?

share|improve this question

migrated from Mar 31 '12 at 3:24

This question came from our site for professional and enthusiast programmers.

I assume that if you would use the control panel to change the timezone, your change wouldn't be squashed on every reboot.

If you are concerned that the timezone is reverting every time you restart, then it sounds like you want to make the change permanent, not temporary, so in that case why don't you just use the control panel?

If this change is just for your web app, then why don't you change the timezone just for the web server instead of globally on the machine? This should be as simple as adding


to the end of /etc/apache2/httpd.conf.

If that doesn't work, it might be because the TZ variable would need to be set before Apache starts instead of being set by Apache. In that case, the following is more complicated, but is sure to work:

  1. Edit /System/Library/LaunchDaemons/org.apache.httpd.plist

    Add the lines


    just before the line that reads </dict> near the bottom

  2. Reload that config

    launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
    launchctl load /System/Library/LaunchDaemons/org.apache.httpd.plist

All of this needs to be done as root.

share|improve this answer
Hi Celada, thanks for your response. What do you mean by 'Control Panel'? Bare in mind I am on a Mac, not Windows. I have found a Timezone option in 'Date & Time' of System Preferences, but saw no option for UTC. – Andy A Mar 30 '12 at 13:55
Not "Control Panel"? The technical term for the individual items in there used to be 'CDev', but I think that term might be obsolete. So, what I mean is whatever they call it these days. Sorry, I am not in front of my MacBook now (it's at home) so I can't check. Anyway, I'm surprised that there isn't a UTC or UTC-equivalent timezone you can set from there. If you can't find one, then try the Apache SetEnv solution instead? – Celada Mar 30 '12 at 14:28
Ill try the Apache idea. I'm currently looking for the file I need to add this to. ... (if you can guide me, please do) – Andy A Mar 30 '12 at 14:41
Mmm, ye, I'm inexperienced with this. What file do I add the line to? Is it one of the files in the conf folder in my apache-tomcat-7.0.26 folder? (Thats a complete guess) – Andy A Mar 30 '12 at 14:52
I updated the question with more information about how to set an environment variable to Apache. HOWEVER, I see from your latest comment that you might not be using the Apple-supplied default Apache but rather tomcat. If so, you will need to edit the conf file (for the SetEnv version) or launch script (for the launchctl version) corresponding to that webserver. I am not sure which files those would be for you because I don't know where/how your tomcat installation is done. But I hope you can locate the analogous files. – Celada Mar 30 '12 at 15:01

If the symbolic link works, you can recreate that symbolic link at startup. See Creating launchd jobs

share|improve this answer
up vote 0 down vote accepted

Bingo. I have managed to set my tomcat timezone to UTC. In bin/ I added CATALINA_OPTS=-Duser.timezone=UTC

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .