1

is it possible to set time /t and date /t as a VAR to use as

@echo off
set TIJD=time /T
set DATUM=date /T
echo %TIJD% %DATUM%
pause

2 Answers 2

3

built-in env vars: %TIME% %DATE%

echo %DATE% %TIME%

if you need to further manipulate the values, you can assign these to other variables, to which you can do other operations:

setlocal
set D=%DATE%
set T=%TIME%
echo %D:~10,4%%D:~4,2%%D:~7,2%%T:~,2%%T:~3,2%%T:~6,2%

The output of echo above will be locale dependent, but for me yields, e.g., 20150117144508.

Sign up to request clarification or add additional context in comments.

Comments

1
set  TimeStr=%Time::= %
Echo TimeStr

takes out ilegal characters from Time (replacing the colon with a space).

1 Comment

illegal only, if you want to use it as part of a filename. (You also should mention %date% to make the answer complete)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.