Skip to main content
fix typo
Source Link
gerrit
  • 3.6k
  • 6
  • 29
  • 42

When logging in to remote machine X, by default, date will give the time in the local timezone:

$ date
Mon Nov 17 22:45:47 CET 2014

Note that TZ is not set:

$ export | grep TZ
$ 

So, I set TZ to my own local timezone for every machine I'm on:

$ export TZ=/usr/share/zoneinfo/Canada/Eastern
$ date
Mon Nov 17 16:46:13 EST 2014

The question is, once I have this set, how do I get the time for the system default timezone, i.e. the timezone that applies if I, as a user, do not manually set TZ? Unsetting TZ gives me the UTC time, which is not what I seek:

$ TZ= date
Mon Nov 17 21:47:13 UTC 2014

Interestingly, TZ= date gives UTC time, even when I didn't yet set TZ to anything; yet when I didndidn`t yet set t yet set TZTZ to anything, a simple to anything, a simpledatedate` gave the date in the system default timezone...

When logging in to remote machine X, by default, date will give the time in the local timezone:

$ date
Mon Nov 17 22:45:47 CET 2014

Note that TZ is not set:

$ export | grep TZ
$ 

So, I set TZ to my own local timezone for every machine I'm on:

$ export TZ=/usr/share/zoneinfo/Canada/Eastern
$ date
Mon Nov 17 16:46:13 EST 2014

The question is, once I have this set, how do I get the time for the system default timezone, i.e. the timezone that applies if I, as a user, do not manually set TZ? Unsetting TZ gives me the UTC time, which is not what I seek:

$ TZ= date
Mon Nov 17 21:47:13 UTC 2014

Interestingly, TZ= date gives UTC time, even when I didn't yet set TZ to anything; yet when I didnt yet set TZto anything, a simpledate` gave the date in the system default timezone...

When logging in to remote machine X, by default, date will give the time in the local timezone:

$ date
Mon Nov 17 22:45:47 CET 2014

Note that TZ is not set:

$ export | grep TZ
$ 

So, I set TZ to my own local timezone for every machine I'm on:

$ export TZ=/usr/share/zoneinfo/Canada/Eastern
$ date
Mon Nov 17 16:46:13 EST 2014

The question is, once I have this set, how do I get the time for the system default timezone, i.e. the timezone that applies if I, as a user, do not manually set TZ? Unsetting TZ gives me the UTC time, which is not what I seek:

$ TZ= date
Mon Nov 17 21:47:13 UTC 2014

Interestingly, TZ= date gives UTC time, even when I didn't yet set TZ to anything; yet when I didn`t yet set TZ to anything, a simple date gave the date in the system default timezone...

Source Link
gerrit
  • 3.6k
  • 6
  • 29
  • 42

Get time for system default timezone

When logging in to remote machine X, by default, date will give the time in the local timezone:

$ date
Mon Nov 17 22:45:47 CET 2014

Note that TZ is not set:

$ export | grep TZ
$ 

So, I set TZ to my own local timezone for every machine I'm on:

$ export TZ=/usr/share/zoneinfo/Canada/Eastern
$ date
Mon Nov 17 16:46:13 EST 2014

The question is, once I have this set, how do I get the time for the system default timezone, i.e. the timezone that applies if I, as a user, do not manually set TZ? Unsetting TZ gives me the UTC time, which is not what I seek:

$ TZ= date
Mon Nov 17 21:47:13 UTC 2014

Interestingly, TZ= date gives UTC time, even when I didn't yet set TZ to anything; yet when I didnt yet set TZto anything, a simpledate` gave the date in the system default timezone...