severity 705566 normal
thanks

Laurence Maddox wrote:
> I get this output:
> Current default time zone: 'America/Chicago'
> Local time is now:      Tue Apr 16 14:45:29 CDT 2013.
> Universal Time is now:  Tue Apr 16 19:45:29 UTC 2013.

Looks okay.  What output did you expect?

> I need to view on the CLI the time in various timezones.
> ...
> I have searched for the "right" way to complete my task, and found a link 
> here:
> http://www.linuxquestions.org/questions/programming-9/display-different-timezones-in-command-line-927660/
> 
> That link recommends that I complete my task using a command like this one:
> TZ=UTC date && TZ=CDT date && TZ=IST date

The concept is reasonable but you must pick a correct timezone for
what you want to accomplish.  UTC is okay.  But CDT and IST are
meaningless to libc.  The GNU libc has no concept of invalid
timezones.  If a timezone doesn't match anything else then the default
is that it is a name for UTC.  So basically you have asked for UTC
three times in a row.

> However, I get this output, which is obviously not what it should be:
> Tue Apr 16 19:45:39 UTC 2013
> Tue Apr 16 19:45:39 CDT 2013
> Tue Apr 16 19:45:39 IST 2013

Try this:

  $ env TZ=US/Eastern date
  Sun May  5 19:37:04 EDT 2013

  $ env TZ=US/Central date
  Sun May  5 18:37:07 CDT 2013

  $ env TZ=US/Mountain date
  Sun May  5 17:37:07 MDT 2013

  $ env TZ=US/Pacific date
  Sun May  5 16:37:08 PDT 2013

However the named timezones are ambiguous.  The use of the above
legacy format is really terrible for knowing for sure what time it is
and which timezone you are in.  That is the entire reason for the
standard time strings.  I use and recommend -R to print the time
string in an unambiguous standard format.

  $ env TZ=US/Mountain date -R
  Sun, 05 May 2013 17:43:03 -0600

See also the FAQ where there is extensive discussion of using the date
command for this task.

  
http://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e

Bob

Attachment: signature.asc
Description: Digital signature

Reply via email to