Write a NumPy program to convert numpy datetime64 to Timestamp.
import numpy as np from datetime import datetime dt = datetime.utcnow() print("Current date:") print(dt) dt64 = np.datetime64(dt) ts = (dt64 - np.datetime64('1970-01-01T00:00:00Z')) / np.timedelta64(1, 's') print("Timestamp:") print(ts) print("UTC from Timestamp:") print(datetime.utcfromtimestamp(ts))
Sample Output:
Current date: 2017-04-01 08:01:12.722055 Timestamp: 1491033672.72 UTC from Timestamp: 2017-04-01 08:01:12.722055
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer