简体   繁体   中英

Converting timestamp with milliseconds to datetime in python

ALL,

I'm trying to get a statistical data of the file. Doing so gives me following:

atime - datetime timestamp representation
atime_nano - nano-seconds resolution in addition to a_time.

What I'd like to do is to convert atime.atime_nano to a datetime variable in Python.

So if I have:

atime = 1092847621L
atime_nano = 7100000L

I'd like to convert it to the datetime object in python that will have correct date with the milliseconds.

How can I do that?

Thank you.

日期时间可以具有微秒(1微秒= 1000纳秒)。对于示例,您可以执行以下操作:

   dt = datetime.fromtimestamp(1092847621L).replace(microsecond = 7100000L/1000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM