Powershell 时间相关
生活随笔
收集整理的這篇文章主要介紹了
Powershell 时间相关
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.時間相差秒數計算
$start = Get-Date Get-HotFix $end = Get-Date Write-Host -ForegroundColor Red ('Total Runtime: ' + ($end - $start).TotalSeconds)//若開始時間保存為字符串$startTime = Get-Date -Format 'yyyyMMddTHH:mm:ss' $startTime=[datetime]::ParseExact("$startTime","yyyyMMddTHH:mm:ss", $null)$EndTime = Get-Date -Format 'yyyyMMddTHH:mm:ss' $EndTime=[datetime]::ParseExact("$EndTime","yyyyMMddTHH:mm:ss", $null)$apiTime=($EndTime - $startTime).TotalSeconds2.獲取文件時間
$(Get-Item abc.txt) 表示獲取文件的句柄; $(Get-Item abc.txt).creationtime 獲取文件創建時間 $(Get-Item abc.txt).lastaccesstime 獲取文件最后訪問時間 $(Get-Item abc.txt).lastwritetime 獲取文件修改時間?
總結
以上是生活随笔為你收集整理的Powershell 时间相关的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PS2019摄影后期处理(三)通透...
- 下一篇: powershell 启动线程与关闭线程