python numpy datetime64 today

python numpy datetime64 today

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
>>> import numpy as np
>>> import datetime
>>> today = np.datetime64(datetime.datetime.now())
>>> today
numpy.datetime64('2018-07-12T19:12:39.167044')
>>> past = np.datetime64('2018-01-01')
>>> past
numpy.datetime64('2018-01-01')
>>> dif = today - past
>>> dif
numpy.timedelta64(16657959167044,'us')
>>> dif = np.timedelta64(dif, 'D')
>>> dif
numpy.timedelta64(192,'D')
>>> dif.astype(int)
192

more on searchfor.space