MozillaZine

Time and time zone settings

From MozillaZine Knowledge Base

This page describes how to check your time and time zone in any Mozilla application.

Time and time zone issues are particularly important in e-mail applications (Thunderbird, Mozilla Suite and SeaMonkey) and in calendar applications (Sunbird, Calendar extension and Lightning).

Contents

Introduction

A Mozilla application has no clock of its own. It uses your system clock. Your system clock is controlled by your operating system settings.

Your operating system has two main time settings:

  • The current time. Your system clock must match local clocks in your region.
  • Your time zone. Your system time zone must match the time zone of your region.

Your time zone has two parts to it:

  • The current offset from Universal Time (known as UT, UTC or GMT). The offset affects your system's relationship to times in other regions—for example, if you receive e-mail from another country.
  • Your region's rules for daylight saving time. These rules affect times on dates in the past and the future.

You can use your Mozilla application to check some of these settings. Some other settings are more difficult to check, and some daylight saving time (DST) issues are too difficult for general-purpose software to resolve. In general, when DST goes into effect and adds one hour, for example, this moves the local time forward by one hour and moves your time zone by +1 hour, thus the time stays the same relative to UTC.

Checking your system time

To check your system time in a Mozilla application, from the main menu bar choose Tools – JavaScript Console (or Tools – Web Development – JavaScript Console, or Tools – Error Console).

In the JavaScript Console, ensure that the All button is pressed.

Copy the expression below, and paste it in the field near the top of the JavaScript console:

Date()

Press the Evaluate button. The JavaScript Console displays your current date, local time, offset from GMT and time zone.

Check that all four parts of this information are correct.

Checking your time zone

As a further check on your time zone, you can check UTC (GMT).

In the JavaScript Console, copy the expression below, and paste it in the field near the top:

(new Date).toUTCString()

Press the Evaluate button. The JavaScript Console displays your system's current UTC (GMT) date and time. This is not the local time on your clock.

To check your system's UTC (GMT) date and time, compare it with the date and time on this web page: UTC timezone

Note:  The web page is in the United States but you can use it no matter where you are, because UTC is always the same everywhere in the world.

Changing your time and time zone settings

To change your time and time zone settings, use your operating system. The details depend on which operating system you are using. If your operating system supports different desktop programs, then the details might also depend on which desktop you are using.

Windows

Either double-click the time in your system tray, or open the Date/Time object in Control Panel.

A Windows bug

A Windows bug can affect time zones in Mozilla applications.

To check your system, use the System Configuration Utility (MSCONFIG) or another method to look for an environment variable named TZ.

One way to check is to open an MS-DOS command prompt, then type the command:

ECHO %TZ%

The reply ECHO is on means that TZ is not set, so you do not need to do anything.

If TZ is set, remove it. For example, you might be able to remove it by editing the file C:\AUTOEXEC.BAT and restarting your system.

If some other program needs TZ, use a batch file to set TZ and start that program.

Macintosh

On Mac OS X, please go to System Preferences > Date & Time.

Unix

Setting System Time
To set the system clock under Linux, use the date command. As an example, to set the current time and date to July 31, 11:16pm, type ``date 07312316 (note that the time is given in 24 hour notation). If you wanted to change the year as well, you could type ``date 073123161998. To set the seconds as well, type ``date 07312316.30 or ``date 073123161998.30. To see what Linux thinks the current local time is, run date with no arguments.
Setting your timezone
The timezone under Linux is set by a symbolic link from /etc/localtime[1] to a file in the /usr/share/zoneinfo[2] directory that corresponds with what timezone you are in. For example, since I'm in South Australia, /etc/localtime is a symlink to /usr/share/zoneinfo/Australia/South. To set this link, type: ln -sf ../usr/share/zoneinfo/your/zone /etc/localtime Replace your/zone with something like Australia/NSW or Australia/Perth. Have a look in the directories under /usr/share/zoneinfo to see what timezones are available.

Times and time zones in e-mail

The date and time of an e-mail are set by the program that sends the e-mail, and stored in the e-mail as a Date header.

To see the original Date header, select the e-mail. Then from the menu bar choose View – Message Source. In the headers at the top of the source, look for the line that begins: Date:

The Date header contains a date and time, but it does not contain complete time zone information—only the offset from GMT. The time that you see in the header is normally the local time in the place where the e-mail was written.

For example, here is a Date header in an e-mail sent from New York at 9:23 AM New York time:

Date: Wed, 01 Mar 2006 09:23:18 -0500

To verify the date and time, you can also check the Received headers. These are stored by the servers that relayed the e-mail between the sender and you.

Any of these headers might be wrong if the computer that stored the header has wrong settings, or if the e-mail is spam with fake headers.

Displayed dates and times

When your e-mail program displays the e-mail's date and time, it normally converts them to your time zone. If your computer's time zone settings are wrong, then you will see the wrong time (and possibly the wrong date).

To turn this conversion off, you can use a preference setting. It affects the headers that you see in e-mails that you open or preview, but it does not affect the Date column in folders.

In your user.js file:

user_pref("mailnews.display.original_date", true);

Or in about:config, search for original then set mailnews.display.original_date to the value true.