'Extract time from date time and find difference between 2 times

I am trying to convert EPOC time to date time and need to extract the time only from that

I am doing below

 $min = $Time_Start | measure -Minimum
 $max = $Time_End | measure -Maximum
 [datetime]$oUNIXDatemin=(Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($min.Minimum))
 $oUNIXDatemin_1 = $oUNIXDatemin.ToString("HH:mm:ss")
 [datetime]$oUNIXDatemax=(Get-Date 01.01.1970)+([System.TimeSpan]::fromseconds($max.Maximum))
 $oUNIXDatemax_1 = $oUNIXDatemax.ToString("HH:mm:ss")

Problem is while converting I am getting $oUNIXDatemin_1 and $oUNIXDatemax_1 value like

$oUNIXDatemin_1

12 October 2021 07:46:46

$oUNIXDatemax_1

12 October 2021 21:16:04

My EPOC values are

$min.Minimum
1634024806

$max.Maximum
1634073364

Please let me know what is wrong here. Need to find the difference in HH:mm:ss format.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source