Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change date and time format via command prompt

I was just wondering, in Windows 7 and above, is it possible to change the way dates and times are displayed via the command prompt? Yes, I'm in the U.S. but I like doing things the European way:

(In Clock/Language/Region)

Short Date: Set as "d/M/yyyy"

Long Date: Set as "dddd, d MMMM yyyy"

Short Time: Set as "HH:mm"

Long Time: Set as "HH:mm:ss"

like image 777
El Ectric Avatar asked Apr 19 '16 18:04

El Ectric


People also ask

How do I change the time on my computer using command prompt?

Type "time" into the command prompt window and press "Enter." The current time setting will now display. To change it, type the proper time into the window in the "00:00:00" 24-hour format -- for example, "13:30:00" for 1:30 p.m. -- and press "Enter." The new time will now be saved.

Can you change the system date with the date command?

Though counterintuitive, the Linux “date” command displays the time, as well as the date, on a Linux box. You can set the date and time on your Linux system clock using the “set” switch along with the “date” command. Note that simply changing the system clock does not reset the hardware clock.

How do I change the style in CMD?

Click the C:\ icon in the upper-left corner of the command prompt window. From the drop-down menu, click the setting for Properties. From the Properties window, click the Layout tab.


1 Answers

Yes, it's possible e.g. using reg add command.
Check the HKEY_CURRENT_USER\Control Panel\International registry key:

reg query "HKCU\Control Panel\International"

For instance, query Short Time format:

reg query "HKCU\Control Panel\International" /V sShortTime

and set it to desired value:

reg add "HKCU\Control Panel\International" /V sShortTime /T REG_SZ /D HH:mm /F

If value name or data contains spaces, use double quotes (surrounding double quotes would not be written to registry):

reg add "HKCU\Control Panel\International" /V sShortTime /T REG_SZ /D "HH:mm" /F

A word of warning: Changing this registry value changes the settings in the user's profile, so it may have side effects in other areas. For example the way the clock is displayed in the task bar. And maybe it breaks other scripts that expect another time/date format.

So be careful when using this trick in something which you give to others!

like image 135
JosefZ Avatar answered Oct 23 '22 04:10

JosefZ