#Batch file time 24 hour format windows#
"echo %time:~-11,2%-%time:~-8,2%-%time:~-5,2%" OS/2 (CMD.EXE) Display the current system time: Windows (CMD.EXE) To set the computer clock to 3:42 P.M., either of the following commands can be used: 4DOS.
Expects a time format of HH:MM:SS or H:MM:SS SET HOURtime:0,2 SET. For example, to add dashes instead of a colon between the HH:MM:SS you would type this: ECHO OFF : Sets the proper date and time stamp with 24Hr Time for log file. You can also string parts together to create a custom format in whatever combo you need also. To set the variable "hour" to the current hour you would type this: For example, if the input time is coming from a server that is three hours ahead of your local time, type -3 in the Hours field to set the output time (your local. Type a number in any of the following fields to adjust the output time from the input time. To grab the minutes the command would be "echo %time:~8,2%" Type the format that you want to convert the input time to. No path is included so it must be run from within the same folder as. You are basically telling it to display the %time% variable - "echo %time.", count 11 characters backwards from the end of the string - ".:~11." and grab 2 characters from that point - ".,2%" Here is a rudimentary batch file that should do the job. To get just the hour out of this string, type "echo %time:~-11,2%" to display just the first 2 characters. The current time is: 17:33:31.35 Enter the new time: To keep the current time and return to the command prompt, press ENTER. To display the current system time, followed by a prompt to enter a new time, type: Copy. Typing "echo %time%" in a cmd prompt returns something like this: To change the current system time to 5:30 PM, type either of the following: Copy. What you have to do is basically use the %time% variable and specify to count a certain number of characters into the string to extract the part you want.