更改Windows时间和日期格式

时间:2015-02-26 17:54:51

标签: powershell

我希望在Windows机器上自动执行操作系统中使用的日期和时间格式的首选项。

我可以使用哪些PowerShell命令来自动执行更改值的任务?

  • 短日期格式
  • 短期和长期格式

这些options are buried deep in Control Panel.

enter image description here

enter image description here

3 个答案:

答案 0 :(得分:7)

我相信您要查找的设置位于:

HKEY_CURRENT_USER\Control Panel\International\sLongDate
HKEY_CURRENT_USER\Control Panel\International\sShortDate
HKEY_CURRENT_USER\Control Panel\International\sTimeFormat
HKEY_CURRENT_USER\Control Panel\International\sYearMonth

所以,

Set-ItemProperty -Path "HKCU:\Control Panel\International" 
                 -name sLongDate -value "<Whatever format you'd like>"

答案 1 :(得分:0)

基于p.campbell的答案的完整示例:

Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sLongDate -Value "dddd, d. MMMM yyyy";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sShortDate -Value "dd.MM.yyyy";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sTimeFormat -Value "HH:mm:ss";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sYearMonth -Value "MMMM yyyy";

答案 2 :(得分:0)

基于p.campbells的回答,但具有所有属性:

Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sCountry -Value "Germany";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sLongDate -Value "dddd, d. MMMM yyyy";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sShortDate -Value "dd.MM.yyyy";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sShortTime -Value "HH:mm";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sTimeFormat -Value "HH:mm:ss";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name sYearMonth -Value "MMMM yyyy";
Set-ItemProperty -Path "HKCU:\Control Panel\International" -Name iFirstDayOfWeek -Value 0;
相关问题