简体   繁体   English

如何在 powershell 中获取此 Get-Date 格式?

[英]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.

相关问题 如何以适合在文件/文件夹名称中使用的格式在 Windows 命令行上获取当前日期/时间? - How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name? 如何在将日期格式设置为另一种格式的计算机上获取格鲁吉亚日期格式? - How can I get georgian date format in a machine which date format set to another format? 如何在Powershell中正确格式化该对象? - How do I properly format this object in powershell? 如何获取Windows PowerShell中的当前用户名? - How do I get the current username in Windows PowerShell? 如何在PowerShell中的Windows 8之前获得NetworkCategory? - How do I get the NetworkCategory prior to Windows 8 in PowerShell? 如何在批处理文件中以特定格式获取日期 - How to get date in a perticular format in batch file 如何获取多个目录中文件的最后修改日期? - How do I get the last modified date of a file in multiple directories? 如何让 powershell 或 windows 终端使用 ANSI 转义码打印彩色文本? - How do I get powershell or windows terminal to print color text using ansi escape codes? C#,如何在Windows Powershell(Windows 10)上配置Mono? (环境变量PATH) - C#, How Do I Get Mono Configured on Windows Powershell (Windows 10)? (Environmental Variable PATH) 如何获取Windows批处理文件中的日期格式为'yyyymmdd'? - How to get the date format in windows batch file as 'yyyymmdd'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM