[英]How do I get this Get-Date format in powershell?
So, I'm trying to calculate the retirement date using Get-Date in Powershell.所以,我试图在 Powershell 中使用 Get-Date 计算退休日期。 I only want to see the date, no time but also with the day of the week.我只想看日期,没有时间还要看星期几。 I've been trying to use methods, no formats.我一直在尝试使用方法,没有格式。 But even with using formats it does not seem to work.但即使使用格式,它似乎也不起作用。
(Get-Date -Day 12 -Month 12 -Year 2000).addYears(67).ToLongDateString()
December 12, 2067
I'd like to see something like Tuesday, December 12, 2067. This is the last part of my script, I've been trying to do this for a while but can't seem to figure it out.我希望看到类似 2067 年 12 月 12 日,星期二的内容。这是我脚本的最后一部分,我已经尝试这样做了一段时间,但似乎无法弄清楚。
Check out custom date and time format strings .查看自定义日期和时间格式字符串。
(Get-Date -Day 12 -Month 12 -Year 2000).addYears(67).ToString("dddd, MMMM d, yyyy")
The result is as you wanted:结果如你所愿:
Monday, December 12, 2067
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.