Discussion:
[Numpy-discussion] UTC-based datetime64
Francesc Alted
2015-08-26 15:38:20 UTC
Permalink
Hi,

We've found that NumPy uses the local TZ for printing datetime64 timestamps:

In [22]: t = datetime.utcnow()

In [23]: print t
2015-08-26 11:52:10.662745

In [24]: np.array([t], dtype="datetime64[s]")
Out[24]: array(['2015-08-26T13:52:10+0200'], dtype='datetime64[s]')

Googling for a way to print UTC out of the box, the best thing I could find
is:

In [40]: [str(i.item()) for i in np.array([t], dtype="datetime64[s]")]
Out[40]: ['2015-08-26 11:52:10']

Now, is there a better way to specify that I want the datetimes printed
always in UTC?

Thanks,
--
Francesc Alted
Chris Barker
2015-09-02 00:28:56 UTC
Permalink
Post by Francesc Alted
Googling for a way to print UTC out of the box, the best thing I could
In [40]: [str(i.item()) for i in np.array([t], dtype="datetime64[s]")]
Out[40]: ['2015-08-26 11:52:10']
Now, is there a better way to specify that I want the datetimes printed
always in UTC?
maybe, but it's a kludge no matter how you do it :-(

It's been in the list for a while to fix this, but hasn't happened yet.
Partly due to me not finishing writing out the notes from SciPy 2014 where
we discussed a way forward on this.

Sorry,

-Chris
Post by Francesc Alted
Thanks,
--
Francesc Alted
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

***@noaa.gov
<javascript:_e(%7B%7D,'cvml','***@noaa.gov');>
--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

***@noaa.gov
Jim Benson
2015-09-02 01:00:20 UTC
Permalink
Post by Chris Barker
Post by Francesc Alted
Googling for a way to print UTC out of the box, the best thing I could
In [40]: [str(i.item()) for i in np.array([t], dtype="datetime64[s]")]
Out[40]: ['2015-08-26 11:52:10']
Now, is there a better way to specify that I want the datetimes printed
always in UTC?
maybe, but it's a kludge no matter how you do it :-(
It's been in the list for a while to fix this, but hasn't happened yet.
Partly due to me not finishing writing out the notes from SciPy 2014 where
we discussed a way forward on this.
Sorry,
-Chris
Plans for getting times in UTC1 at the ms accuracy?

Sorry, a joke, i couldn't resist.

Cheers,

Jim
Post by Chris Barker
Post by Francesc Alted
Thanks,
--
Francesc Alted
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
_______________________________________________
NumPy-Discussion mailing list
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...