如何获得一个万能的Windows批处理文件时间戳 [英] How to get a UNIVERSAL Windows batch file timestamp

查看:877
本文介绍了如何获得一个万能的Windows批处理文件时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在生成Windows批处理文件的时间戳,因为我得到不同的Windows版本diferent日期格式。

I'm having trouble generating a timestamp in a Windows batch file, because I get diferent date formats on different Windows versions.

我的机器:

>echo %date%
>Tue 11/17/2009

友机:

>echo %date%
>11/17/2009

我想必须有获得使用FOR / F两个字符串日期(11/17/2009)的一些方法。我一直在试图与谷歌搜索,并不能找到答案。

I guess there has to be some way of getting the date (11/17/2009) from both strings using for /f. I've been trying and googling and can't find the answer.

有另一种方式来获得一个时间戳,而不使用日期%%?

Is there another way to get a timestamp without using %date%?

推荐答案

使用的VBScript 如果你想获得独立的日期和时间设置:

Use VBScript if you want to get independent date time settings:

thedate = Now
yr = Year(thedate)
mth = Month(thedate)
dy = Day(thedate)
hr = Hour(thedate)
min = Minute(thedate)
sec = Second(thedate)
WScript.Echo yr&mth&dy&hr&min&sec

这篇关于如何获得一个万能的Windows批处理文件时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆