1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
function ConvertFrom-UnixTime {
[CmdletBinding(DefaultParameterSetName = "Seconds")]
param (
[Parameter(Position = 0,
ValueFromPipeline = $true,
Mandatory = $true,
ParameterSetName = "Seconds")]
[int]
$Seconds,
[Parameter(Position = 0,
ValueFromPipeline = $true,
Mandatory = $true, ParameterSetName = "Miliseconds")]
[bigint]
$Miliseconds
)
Begin {
$date = (Get-Date "1970-01-01 00:00:00.000Z")
}
Process {
switch ($PSCmdlet.ParameterSetName) {
"Miliseconds" {
$date = $date.AddMilliseconds($Miliseconds)
}
Default {
$date = $date.AddSeconds($Seconds);
}
}
}
End {
$date
}
}
ConvertFrom-UnixTime '1681230017000'
|