Why is the output of Date[] several hours off?
 The inaccuracies in the hour element of the output of Date and the output of TimeZone is due to Mathematica thinking that your time zone is Greenwich Mean Time (GMT). These Date and TimeZone errors are caused by a subtle change in how compiled programs interact with the time zone database that accompanies the GNU standard C library. The interaction with this database is defined by the version of the GNU standard C library which is used to build Mathematica. Mathematica is statically linked to . If your Linux OS uses , Mathematica will default to a value of 0 for TimeZone when it fails to access the correct value from the time zone database. For example, if you reside in Champaign, Illinois (Central Standard Time), you would see: In[1]:= |  |
Out[1]= |
 |
In[2]:= |  |
Out[2]= |
 |
The results should actually be: In[3]:= |  |
Out[3]= |
 |
In[4]:= |  |
Out[4]= |
 |
Our developers are aware of this problem. We expect to have this fixed by the next major release of Mathematica. Passing a time zone value to Date returns the time for that zone. This can be used to workaround the inaccurate time problem by redefining Date to adjust the time for your time zone. This example would correct the Date function for Central Standard Time. (CST is calculated by subtracting 6 hours from GMT.) In[5]:= |  |
Out[5]= |
 |
In[6]:= |  |
In[7]:= |  |
Out[7]= |
 |
Here is a list of time zones with their corresponding adjustments with respect to GMT. | Midway Island | GMT-11 | | AST—Aleutian Standard | GMT-10 | | AKST —Alaska StandardTime | GMT-9 | | PST—Pacific Standard Time | GMT-8 | | MST—Mountain Standard Time | GMT-7 | | CST—Central Standard Time | GMT-6 | | EST—Eastern Standard Time | GMT-5 | | AST—Atlantic Standard Time | GMT-4 | | part of Greenland | GMT-3 | | Mid–Atlantic | GMT-2 | | AT—Azores Time | GMT-1 | | GMT—Western Europe Time | GMT | | CET—Central Europe Time | GMT+1 | | EET—Eastern Europe Time | GMT+2 | | MSK—Moskow Time | GMT+3 | | Russia Zone 3 | GMT+4 | | Russia Zone 4 | GMT+5 | | Russia Zone 5 | GMT+6 | | Russia Zone 6 | GMT+7 | | Russia Zone 7 | GMT+8 | | Russia Zone 8 | GMT+9 | | Russia Zone 9 | GMT+10 | | Russia Zone 10 | GMT+11 | | Russia Zone 11 | GMT+12 |
You can place the definition of FixedDate in the Kernel's file so that it will be automatically evaluated and ready to use each time the Mathematica Kernel is launched. More information on how to edit the Kernel's file can be found at http://support.wolfram.com/mathematica/kernel/files/initmconfigure.html Download this FAQ as a Mathematica 5.2 Notebook
Questions or comments? Send email to support@wolfram.com.
|