Associate
Hi all,
I'm trying to find a reliable way of using dates and times in Windows batch files. I've been using the following, which works on my XP install, on my works Server 2003 SBS install, but not on some other Server 2003 installs - it's like the date is in a completely different format:
Does anyone know of a reliable way to get the date/time so it will work on all Windows installs, regardless of date format? (ideally, it should be in YYYY-MM-DD HH:MM format, and shouldn't require the use of any extra software to be installed).
Cheers,
Matt
I'm trying to find a reliable way of using dates and times in Windows batch files. I've been using the following, which works on my XP install, on my works Server 2003 SBS install, but not on some other Server 2003 installs - it's like the date is in a completely different format:
Code:
SET NowDate="%date:~6,6%-%date:~3,2%-%date:~0,2%"
SET NowTime="%time:~0,2%-%time:~3,2%"
echo Date: %NowDate% >> c:\test\logs\%NowDate%_%NowTime%.txt
echo Time: %NowTime% >> c:\test\logs\%NowDate%_%NowTime%.txt
echo ------------------ >> c:\test\logs\%NowDate%_%NowTime%.txt
Does anyone know of a reliable way to get the date/time so it will work on all Windows installs, regardless of date format? (ideally, it should be in YYYY-MM-DD HH:MM format, and shouldn't require the use of any extra software to be installed).
Cheers,
Matt