Để nhận được Thời gian bù giờ UTC, hãy sử dụng timestamp.utcoffset () . Đầu tiên, hãy nhập các thư viện được yêu cầu -
import pandas as pd
Tạo dấu thời gian
timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC')
Dấu thời gian mới với ngày và giờ UTC
timestamp.utcnow()
Nhận thời gian bù giờ UTC
timestamp.utcoffset()
Ví dụ
Sau đây là mã
import pandas as pd
# creating a timestamp
timestamp = pd.Timestamp('2021-10-16T15:12:34.261811624', tz='UTC')
# display the Timestamp
print("Timestamp...\n", timestamp)
# new timestamp with UTC day and time
print("\nUTC day and time...\n", timestamp.utcnow())
# Get the UTC offset time
print("\nUTC offset time...\n", timestamp.utcoffset()) Đầu ra
Điều này sẽ tạo ra mã sau
Timestamp... 2021-10-16 15:12:34.261811624+00:00 UTC day and time... 2021-10-03 07:56:44.685816+00:00 UTC offset time... 0:00:00