How to get the date?
Note: echo% date is required for testing in CMD, and it can be used directly in bat
Results: Friday, March 13, 2020
How to get time?
Note: echo% time% is required for testing in CMD, and it can be used directly in bat
This is the date and time obtained in the standard format of the system, but sometimes we need to use the specified format. What should we do?
Format% date: ~ x, y% and% time: ~ x, y%
Note: X is the start position, y is the number of characters to get
For example, I want to get the full date and time,
However, if the time is earlier than 10 o’clock, only the date will be displayed and the time will not be displayed, for example: 20200313. How to solve this problem?
In this way, we can achieve our goal and successfully get the date and time.
Command to intercept string with CMD
The first character of echo is% STR: ~ 0,1%
The first two characters of echo are: STR: ~ 0,2%
The first 5 characters of echo are as follows: STR: ~ 0,5%
Echo the string after removing the last character is% STR: ~ 0, – 1%
Echo the string after removing the last three characters is as follows: STR: ~ 0, – 3%
The fourth character of echo is as follows: STR: ~ 3,1%
The fourth and third characters after echo are as follows: STR: ~ 3,4%
The last character of echo is% STR: ~ – 1%
The last character of echo is% STR: ~ – 1,1%
The last character of echo is% STR: ~ – 1,2%
Echo the fourth character to the last is: STR: ~ – 4,1%
The fourth to last character in echo is% STR: ~ – 4%
The fourth to the last character of echo and 1 character after it is% STR: ~ – 4,2%
Echo the fourth to the last two characters are as follows: STR: ~ – 4,3%
Save the above code as pp.bat Run it
Get the start time of each system and hide the startup window systime.vbs :
ws.run “cmd /Q /C @echo %date:~0,4%-%date:~5,2%-%date:~8,2% %date:~10,15% %time% Windows7 Start Up >> c:\Login-Log “,vbhide
This article about getting the current system time under the CMD bat article introduced here, more related to the content of the system time under the CMD, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!