Powershell's Get-date: How to get Yesterday at 22:00 in a variable?

前端 未结 7 1822
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 19:18

For a check i need yesterday\'s date at 10:00pm in a variable.

I get yesterdays Date and current Time with

$a = (get-date).AddDays(-1)
7条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 20:05

    I see this topic, but in my case I was looking for a way to improve the format. Using UFormat and adding -1 day

    (get-date (get-date).addDays(-1) -UFormat "%Y%m%d-%H%M")
    

提交回复
热议问题