How to get date format in Windows batch?

如何在 Windows 批次檔執行時取得指定格式的時間? 我目前遇到的需求是 "2008/12/12 星期五" (預設輸出格式) 轉成 "20081212",透過下述之片段即可達成。

@echo off

FOR /F "tokens=1-4 delims=/ " %%a IN ("%date%") DO (
SET _MyDate=%%a%%b%%c
)

echo %_MyDate%

輸出結果

D:\>date.bat
20081222

D:\>

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database