[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Scripted method to change TZ from UTC to a specific timezone?



James Wu wrote:
> When I run the cmd "date", I get UTC time on a fresh boot of an imaged
> machine. I'd like to find a way to set the time to "America/New_York"
> for automatically via script. A reboot is ok if absolutely needed but
> not preferred.

Use the TZ environment variable to override the current timezone.

  $ date -R
  Fri, 15 Oct 2010 10:10:52 -0600

  $ TZ="America/New_York" date -R
  Fri, 15 Oct 2010 12:10:56 -0400

You might find the GNU coreutils FAQ entry on date interesting
reading.  I think you will find some useful tidbits there.

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

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: