In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to set the date and time format in dos. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The code is as follows:
@ echo off
@ title string editing test (the arrow → ← described below means right and left, respectively)
Set aa=1234567890
Echo description: in the following compound variables, the number before the comma indicates the pointer offset, and the number after the comma indicates the extracted character length
The echo% aa:~1,5% / / pointer offsets 1 bit to the right →, and then extracts 5 characters from the pointer to the right →.
Echo% aa:~0,-3% / / pointer is not offset, → extracts all characters and removes the last 3 characters.
Echo% aa:~5% / / single number, no length value specified. Indicates that the pointer → is offset by 5 characters, and then → extracts all characters.
Echo% aa:~-5% / / A single negative value, a special case, indicates that the pointer is offset in the opposite direction, from the rightmost end, the ← is offset by 5 digits, and then → extracts all characters from the pointer. It can also be simply understood as extracting the last 5 characters of a string.
The case in which the echo pointer is offset in the opposite direction. Both offset from right to left from the rightmost end of the string. ←
The echo% aa:~-2,1% / / offset takes a negative value, which means that the pointer is offset by 2 bits from the rightmost end to the left ←, and then one character is extracted from the pointer to the right → to generate a new variable value. Pay attention to the space at the end of the string, because the space will also be extracted into the variable as a "transparent character". Remember to remove the space at the end of the variable. Ctrl + A can quickly and easily check whether the variable string contains spaces.
From the rightmost end of echo% aa:~-4,3% / /, the pointer ← is offset by 4 bits, and then → extracts 3 characters.
Echo% aa:~-4,-2% / / from the rightmost end, the pointer ← is offset by 4 bits, then from the pointer, → extracts all characters and removes the last 2 characters.
Echo application
Echo% date:~0,10% / / extract year, month and day information
Echo date:~-3% / / extract the day of the week
Echo% time:~0,5% / / time and minutes in extraction time
Echo% time:~0,-3% / / extract time and minute and second information
Pause
Summary:
1. When the offset is positive, the pointer moves to the right; when the offset is negative, the pointer moves to the left from the rightmost end of the string.
2. If the length value is positive, several characters are extracted to the right; if negative, all characters are extracted to the right, and several characters are removed. "several = the absolute value of the length value." The direction of extracting characters is always from left to right.
3. If it is a single number, then this number represents the offset, and the length value is the default value, which is both the "remainder" of the string, that is, all the characters starting from the pointer to the right. If the number is negative, it can be simply understood as: extract several characters at the end of the string. (the correct explanation should be: the pointer is offset in the opposite direction, ← offsets a few bits from the rightmost end, and then → extracts all characters from the pointer.)
■% date% and% time% are built-in date and time variables for the system.
Set date=%Date:~0,4%%Date:~5,2%%Date:~8,2%%Time:~0,2%%Time:~3,2%%Time:~6,2%
% Date:~0,4% represents the year, and so on
The format of the display is 20120515105610
DOS date format settin
% date% and% time%
2008-10-21 21 purl 3411.56
C:\ > echo% date%
Tuesday, October 21, 2008
C:\ > echo% date:~0,4%
2008
Drive letter:\ > output% date% is a parameter, but what he takes after it is the range of values. The following value, the first zero represents the beginning and the next four represents a total of four characters.
C:\ > echo% date:~-3%
Wednesday
The negative number in this represents the reciprocal, which takes the last three characters.
C:\ > echo% date:~-3,-1%
Week
The-1 here does not output the last character-2, of course, two analogies.
Time is similar.
Echo time%
21:34:11.56
DOS commands Date and Time
1. DATA date setting command
Function: set or display the system date.
Type: internal command
Format: date [mm-dd-yy]
Instructions for use:
(1) omit [mm-dd-yy] to display the system date and prompt for a new date. If you do not modify it, you can press enter directly. [mm-dd-yy] is in the format of "month, month, day, day, year and year".
(2) when the machine starts to start and an automatic processing file (AUTOEXEC.BAT) is executed, the system is not prompted to enter the system date. Otherwise, you are prompted for a new date and time.
Example:
To view the date of the current system, enter date directly.
Second, TIME system clock setting command
Function: set or display the system period.
Type: internal command
Format: time [HH: mm:ss:xx]
Instructions for use:
(1) omit [hh:mm:ss:xx], display the system time and prompt for a new time. If you do not modify it, you can press enter directly. [hh:mm:ss:xx] is in the format of "hours: minutes: seconds: several percent of seconds".
(2) when the machine starts to start and an automatic processing file (AUTOEXEC.BAT) is executed, the system is not prompted to enter the system date. Otherwise, you are prompted for a new date and time.
This is the end of this article on "how to set the date and time format in dos". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.