PowerShell日期格式mmddyy [英] PowerShell date format mmddyy

查看:63
本文介绍了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.

我如何做到这一点?

推荐答案

因为 $ a 实际上是

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆