echo %date%

基础知识,基础知识太差了。查了半天,先补补课吧。
“date:~0,10%是DOS里取日期的命令。 

echo :~1,5%      //指针向右→偏移1位,然后从指针处开始向右→提取5个字符.

echo :~0,-3%    //指针不偏移,→提取所有字符,并除去最后3个字符.

echo :~5%        //单个数字,不指定长度值.表示指针→偏移5个字符,然后,→提取所有字符.

echo :~-5%      //单个负值,特例,表示指针反方向偏移,从最右端起,←偏移5位,然后从指针处开始→提取所有字符.也可以简单理解为提取字符串末尾5个字符。

C:\Documents and Settings\user>echo %date%
2012-08-08 星期三
C:\Documents and Settings\user>echo %date:~5,10%
08-08 星期三
C:\Documents and Settings\user>echo %date:~5,4%
08-0
C:\Documents and Settings\user>echo %date:~5,5%
08-08
C:\Documents and Settings\user>

posted on 2018-03-15 12:32  xianguang  阅读(293)  评论(0编辑  收藏  举报

导航