Windows Dos 獲取時間還是比較麻煩的,尤其是獲取昨日時間,以下是可用的幾種方式
Dos cmd %date %time
# cmd 直接執行獲取當前日期 %date:~0,4%%date:~5,2%%date:~8,2%
# %time 獲取當前時間: 時-分-秒 %time:~0,2%-%time:~3,2%-%time:~6,2%
使用powershell
# Dos 下 調用 powershell 獲取時間 # 獲取當前日期,格式:yyyyMMdd powershell -c Get-Date -Format 'yyyyMMdd' # 獲取昨日時間,格式:yyyyMMdd powershell -c (Get-Date).AddDays(-1).ToString('yyyyMMdd')
Getting Yesterday’s Date
獲取昨日日期的一些方式
https://devblogs.microsoft.com/powershell-community/getting-yesterdays-date/