Hiển thị các bài đăng có nhãn Batch. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Batch. Hiển thị tất cả bài đăng

Batch File - Format Date Time

Following are the commands to generate data-time according to your need


Get Current Date


echo %date%

Fri 04/05/2013

Get Current Year


echo %date:~10,4%

2013

Get Current Month


echo %date:~4,2%

04

Get Current Day


echo %date:~7,2%

05

Get Date in "dd-mm-yyyy" Format


echo %date:~7,2%-%date:~4,2%-%date:~10,4%

05-04-2013

Get Current Time


echo %time%

21:41:42.28

Get Current Hour


echo %time:~0,2%

21

Get Current Minute


echo %time:~3,2%

22

Get Current Seconds


echo %time:~6,2%

30

Get DateTime in "dd-mm-yyyy-hh-mm-ss" Format


echo %date:~7,2%-%date:~4,2%-%date:~10,4%-%time:~0,2%-%time:~3,2%-%time:~6,2%

05-04-2013-21-26-12

How To : Blank Line in Batch File or Script.

Problem : How to create or echo a blank line in batch file or script?
Solution : Just add
a period ('.') after the echo command without any space.
echo

As shown above, "echo." will print a blank line for you.

Njoy !!!

-----------------------------------------------------------------

[UPDATE]
However in bash version >4
echo. will fail
echo will work