How to force python print numpy datetime64 with specified timezone?

前端 未结 3 979
孤城傲影
孤城傲影 2021-02-13 23:40

I want to see numpy datetime64 objects by my specified timezone.

>>> import numpy as np
>>> np.datetime64(\'2013-03-10T01:30:54\')
numpy.dateti         


        
3条回答
  •  悲&欢浪女
    2021-02-14 00:09

    You could always set the time zone before printing your datetime64 objects:

    >>> import os, time, numpy
    >>> os.environ['TZ'] = 'GMT'
    >>> time.tzset()
    
    >>> numpy.datetime64(0, 's')
    numpy.datetime64('1970-01-01T00:00:00+0000')
    

提交回复
热议问题