[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Conversion from UTC to specified Timezone
From: |
Mike Miller |
Subject: |
Re: Conversion from UTC to specified Timezone |
Date: |
Thu, 9 Nov 2017 08:20:07 -0800 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
On Thu, Nov 09, 2017 at 05:36:15 -0700, babelproofreader wrote:
> I am looking for a way to convert a UTC time, read from a text file in the
> format YYYY-MM-DD HH:MM:SS, to an equivalent time in a specified time zone,
> i.e. New York time (EST) or London time, taking into account daylight
> savings time when it is in effect. I am hoping there is a native Octave way
> of reading time zone info from /usr/share/zoneinfo/... to make such a
> conversion.
s = "2017-01-01 12:00:00";
setenv ("TZ", "UTC0");
t = mktime (strptime (s, "%Y-%m-%d %H:%M:%S"));
unsetenv ("TZ"); ## or setenv ("TZ", "Europe/London")
tm = localtime (t)
strftime ("%Y-%m-%d %H:%M:%S", tm)
--
mike
signature.asc
Description: PGP signature