Conversion from UTC to specified Timezone [SOLVED]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Conversion from UTC to specified Timezone [SOLVED]

babelproofreader
This post was updated on .
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.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
Help-octave@gnu.org
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Conversion from UTC to specified Timezone

Mike Miller-4
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

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

signature.asc (849 bytes) Download Attachment