Times Stored in IP Fabric
IP Fabric stores times in two different formats: Absolute Time or Relative Time, depending on the type of data.
Absolute Time
This is also known as an Epoch or Unix timestamp and is stored in milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970.
- Inventory → End of Life Milestones:
- End of Sale:
endSale
- End of Maintenance:
endMaintenance
- End of Support:
endSupport
- End of Sale:
- Management → Discovery History:
- Last discovery time:
ts
- Last discovery time:
- Management → Configuration:
- Last Change At:
lastChangeAt
- Last Check At:
lastCheckAt
- Last Change At:
- Discovery Snapshot (
GET /api/{api_version}/snapshots
):- Start Time:
tsStart
- End Time:
tsEnd
- Start Time:
Converting Millisecond Timestamp to ISO Date With Python
import datetime
ts = 1348876800000 # milliseconds
# datetime does not accept milliseconds so must divide by 1,000:
dt = datetime.datetime.utcfromtimestamp(ts/1000).replace(tzinfo=datetime.timezone.utc)
print(dt.isoformat()) # >>> '2012-09-29T00:00:00+00:00'
Relative Time
Relative time (stored in seconds) is the amount of time that has elapsed and does not represent an exact timestamp.
- Inventory → Devices:
- Uptime:
uptime
– Relative to the boot time of the device at the time the command was run on the device.
- Uptime:
- Technology → Routing → * :
- Routes:
- Age:
nhLowestAge
- Age:
- Routing Protocols:
- Session Time or Uptime:
currStateTime
- Session Time or Uptime:
- Routes:
Relative Time Does Not Change
This is relative to the time when the command was run on the device and does not change. For example:
The device reported uptime of
120 Days 5 Hours
whenshow version
was run.
Viewing that snapshot on a day or week later will also show 120 Days 5 Hours
.
Converting Time Interval in Seconds to Human-Readable Format With Python
import datetime
ts = 200700 # seconds
dt = datetime.timedelta(seconds=ts)
print(str(dt)) # >>> '2 days, 7:45:00'
IP Fabric Time Conversion
Time conversion in IP Fabric is done in the frontend and is also formatted when exporting to CSV. The data returned via the API will always be in milliseconds or seconds. This may differ from other time conversion websites, as seen in the example from epochconverter.com:
Time conversion (in seconds):
Human-Readable Time | IP Fabric | epochconverter.com |
---|---|---|
1 minute | 60 | 60 |
1 hour | 3 600 | 3 600 |
1 day | 86 400 | 86 400 |
1 week | 604 800 | 604 800 |
1 month | 2 629 800 (30.4375 days) |
2 629 743 (30.44 days) |
1 year | 31 557 600 (365.25 days) |
31 556 926 (365.24 days) |