Batch file create date parameter

Often I use a batch file to format folders or files based on the current time. This will set a variable that is the current date/time formatted as YYYYMMDDHHMMSS:

@echo off

rem --------------------------------------------
rem ------- SET UP DATETIME STAMP VARIABLE -----
rem --------------------------------------------
@echo off
for /f "delims=" %%a in (' powershell -Command "Get-Date -format yyyyMMddHHmmss" ') do set "dtformatted=%%a"
echo %dtformatted%

rem ECHO %dtformatted%
rem --------------------------------------------