Hello. By snmp I get uptime glands: Timeticks: (478549248) 55 days, 9: 18: 12.48 easysnmp in python gets only ms. The fact that in brackets (478549248) How to lead to such a view 55 days, 9: 18: 12.48?

    2 answers 2

    In general, 478549248 milliseconds is about 5.5 days

    from datetime import timedelta x = 478549248 d = dtimedelta(milliseconds = x) # 4th argument - milliseconds print d >>> 5 days, 12:55:49.248000 

    if you count

     timedelta(x * 10) --> 55 days, 9:18:12.480000 
    • Thanks for the help. It works as it should! - Coveraver
    • @Jfs, yes you are right of course - andy.37

    You have units not milliseconds:

     >>> from datetime import timedelta >>> timedelta(days=55, hours=9,minutes=18, seconds=12.48)//timedelta(milliseconds=1) 4785492480 

    Your number should be multiplied by 10 in order to get milliseconds:

     >>> str(timedelta(milliseconds=10*478549248)) '55 days, 9:18:12.480000'