DOS Date and Time

Source: Internet
Author: User
This article is based on: Http://www.jb51.net/article/30527.htm


In dos, we can get the current date through the dynamic variable date, and get the current date through the dynamic variable % time %. Instance 1

C: \ Users \ hubin5> echo % date % 2013/03/11 Monday c: \ Users \ hubin5> echo % time % 13:42:24. 29

Instance 2Set NO = % Date :~ 0, 4% % Date :~ 5, 2% % Date :~ 8, 2% % time :~ 0, 2% % time :~ 3,2% % time :~ 6, 2% % Date :~ 20120515105610 indicates the year, and so on. The format is. Because the time (time) is less than 10, the first digit of the time variable is a space, that is, 8:31:41. 75. In this case, we may need to remove the space, that is, 8:31:41. 75. We may implement the following scripts: Instance 2-1

Set NO = % Date :~ 0, 4% % Date :~ 5, 2% % Date :~ 8, 2% set T = % time % if "% T :~ 0% % "=" "(set T = T :~ 1%) set no = % Date :~ 0, 4% % Date :~ 5, 2% % Date :~ 8, 2% % T :~ 0, 2% % T :~ 3,2% % T :~ 6, 2% In instance 2 and instance 2-1We use some operations on the string value of the environment variable. For details, refer to "processing strings in dos". Ii. Date setting commandFunction: set or display the system date. Type: Internal Command Format: Date [mm-dd-yy] usage instructions: (1) omitting [mm-dd-yy] displays the system date and prompts you to enter a new date, if you do not change the value, you can directly press the Enter key. [mm-dd-yy] is in the format of "month, month, day, day, and year". (2) when the machine starts to start, Automatic File Processing (autoexec. BAT) is executed, the system does not prompt to enter the system date. Otherwise, the system prompts you to enter a new date and time. Instance: view the date of the current system. Enter date directly. Iii. Time system clock setting commandFunction: set or display the system period. Type: Internal Command Format: time [hh: mm: SS: XX] usage instructions: (1) omitted [hh: mm: SS: XX], displays the system time and prompts you to enter a new time. If you do not modify the time, press the Enter key directly. The format of [hh: mm: SS: XX] is "hour: minute: Second: % seconds; (2) Automatic File Processing (autoexec. BAT) is executed, the system does not prompt to enter the system date. Otherwise, the system prompts you to enter a new date and time. End!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.