Retrieving "Last Sync Time" from vSphere Replication API and VMware Live Recovery
search cancel

Retrieving "Last Sync Time" from vSphere Replication API and VMware Live Recovery

book

Article ID: 426444

calendar_today

Updated On:

Products

VMware Live Recovery

Issue/Introduction

vSphere Replication has various APIs that will allow retrieving the last sync time of a replication pair but the value is not easily understandable as a specific date and time.

Environment

VMware Live Recovery

Cause

As described in the Broadcom Developer Portal for the REST API, this value is stored as an epoch time and needs to be converted to a datetime format that is human readable.

Resolution

To read the last sync time, the value needs to be converted to a datetime object. Below are examples of how to do so in Python and Powershell.

Powershell

$EpochTimeInt64 = <LastSyncTime> # Input last sync time as the value
$EpochTimeSeconds = $EpochTimeInt64/1000
$DateTimeOffset = [System.DateTimeOffset]::FromUnixTimeSeconds($EpochTimeSeconds)

# Convert to UTC Time
$UtcDateTime = $DateTimeOffset.UtcDateTime

# Display the DateTime object
Write-Host "UTC Time: $UtcDateTime"

Python

from datetime import datetime

epoch_time = <last_sync_time>  # Input last sync time as the value

dt_object = datetime.utcfromtimestamp(epoch_time)
formatted_time = dt_object.strftime('%Y-%m-%d %H:%M:%S')
print(formatted_time)