Powershell - 更简单的方法来获取文件名的简短日期

mho*_*100 3 powershell replace date

更多出于好奇,因为它对我来说工作正常(我刚刚开始使用Powershell)但我正在使用下面的文件名来获取短日期:

$shortdate = (get-date).toshortdatestring().replace("/",".")
Run Code Online (Sandbox Code Playgroud)

是否有内置功能,或者这是实现此目的的正确方法吗?

zda*_*dan 6

您可以使用以下-Format参数get-date:

get-date -format "MM.dd.yyyy"
11.20.2012
Run Code Online (Sandbox Code Playgroud)