我正在从一台远程计算机获得EPOC时间,与本地系统相比,它存在于不同的时区。我想在EPOC的时间上增加7-8分钟的时间。我能用powershell做这件事吗?
时代是precision rfc3339
的时代
例如,我将current time 1641960490800
作为远程机器的时间,我想在其中添加7-8分钟,并以与1641960817177
相同的格式打印它。
找不到类似的职位
发布于 2022-01-12 06:13:34
由于您依赖于一个应用程序来交付时间,所以您可能需要在添加时间之前解析它。有点像
precision rfc3339 |
# parse the number out
Select-String -Pattern '\d+' |
Select-Object -ExpandProperty Matches |
# retrieves just the number
Select-Object -ExpandProperty Value |
# adds 8 minutes (*60seconds)
# order is important so that it converts the string into a number type
ForEach-Object {60*8 + $_}
或者,如果这看起来令人望而生畏,技术上有一种非管道方法:
$(precision rfc3339) -Match '\d+'
60*8 + $Matches[1]
就个人而言,虽然它看起来有点复杂,但我认为PowerShell在使用它的管道时是最强的,但这是一个风格/选择的问题。
https://stackoverflow.com/questions/70676883
复制相似问题