Pmi*_*e86 15 powershell datetime
我需要转换"08"来显示"八月"
我无法使用,Get-Date因为这来自fileName,它可能会也可能不会改变.
因此,目前我将名称拆分为数组,访问我需要的数据,并需要将mm部分转换为MMMM
01 = January
03 = March
etc
Run Code Online (Sandbox Code Playgroud)
Roh*_*rds 19
全月名称:
(Get-Culture).DateTimeFormat.GetMonthName(8)
Run Code Online (Sandbox Code Playgroud)
简写:
(Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(8)
Run Code Online (Sandbox Code Playgroud)
本着使用最简单的方式的精神:
Get-Date -UFormat %B
或者获取月份的缩写:
Get-Date -UFormat %b
这也可以很好地从 BASH 和其他使用这种日期格式的脚本语言移植。
小智 6
(Get-Culture).DateTimeFormat.GetMonthName((Get-Date).Month)
Run Code Online (Sandbox Code Playgroud)
小智 6
如果您正在查找当前月份,请尝试以下操作:
$currentMonth = Get-Date -UFormat %m
$currentMonth = (Get-Culture).DateTimeFormat.GetMonthName($currentMonth)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19589 次 |
| 最近记录: |