PowerShell日期格式mmddyy [英] PowerShell date format mmddyy
本文介绍了PowerShell日期格式mmddyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以使用PowerShell在PowerShell中为变量设置日期
I know I can set a date to a variable in PowerShell using
$a = Get-Date
它很好用,但是当浏览有关格式化日期的文档时, MMDDYY
没有一个.
It works great, but when looking through the documentation on formatting the date, there wasn't one for MMDDYY
.
我如何做到这一点?
推荐答案
Because $a
is effectively a System.DateTime. You can do:
$a = Get-Date
Write-Host $a.ToString('MMddyy')
Full details on custom Date and Time Format Strings are in Custom Date and Time Format Strings.
这篇关于PowerShell日期格式mmddyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文