时间戳转北京时间的powershell实现

2024-02-06 12:11:10 浏览数 (1)

时间戳转北京时间的powershell实现,示例:

代码语言:powershell复制
 $timestamps = @(
    1706845225,
    1706845194,
    1706845141,
    1706845117,
    1706845033,
    1706845003,
    1706844979,
    1706844960,
    1706844837,
    1706844824
)

foreach ($timestamp in $timestamps) {
    $utcTime = [DateTimeOffset]::FromUnixTimeSeconds($timestamp)
    $beijingTime = $utcTime.ToOffset([TimeSpan]::FromHours(8))
    Write-Output $beijingTime.DateTime
}

0 人点赞