I have a process in which I read a bunch of lines in ISO 8601 format in Zulu or UTC. For instance,
2012-06-20T21:15:00Z 2012-06-20T21:16:00Z 2012-06-20T21:17:00Z 2012-06-20T21:18:00Z
I convert strings to datetime objects related to the time zone and save them in binary format as integers, converting them to Unix timestamps. For instance,
dt_str = '2012-06-20T21:15:00Z' ts = int(mktime(datetime.strptime(dt_str, '%Y-%m-%dT%H:%M:%SZ').timetuple())) # ts = 1340241300
When I read these timestamps back to another process, I would like to instantiate the numpy.datetime64 object directly from the timestamp. The problem is that datetime64 sets the timezone for my local timezone.
np_dt = np.datetime64(ts,'s') # np_dt = numpy.datetime64('2012-06-20T21:15:00-0400')
Does anyone know a way that I could read in my timestamp, so what is UTC time? I would like for np_dt to be equal to numpy.datetime64 ('2012-06-20T21: 15: 00-0000') ... I think.
Hi
source share