Find knowledge base article(s) by searching for keywords in the title e.g. type linux in the search box below
Find knowledge base article(s) by browsing the subject categories of articles
Technology quick references, cheatsheets, user manuals etc.
Shop Online through ShopifyLite
Tutorials on various IT applications.
Search Title    (UL:0 |SS:f)

Software >> OS >> Windows >> Command Line >> How to create a variable from date and time commands

(1) Method 1 for /f "tokens=2-4 delims=/ " %%a in ('Date /T') do set DateVar=%%c-%%a-%%b for /f "tokens=1-3 delims=: " %%a in ('TIME /T') do set TimeVar=%%a:%%b:%%c echo %DateVar% echo %TimeVar% To ensure 24 hour format for time, do a customisation of the Regional and Language Options from Control Panel (2) Method 2 @echo off for /f "tokens=1-2 delims=." %%a in ('echo %time%') do set TimeA=%%a& set hsec=%%b for /f "tokens=1-3 delims=:" %%a in ('echo %TimeA%') do set hh=%%a& set mm=%%b& set ss=%%c echo %hh%%mm%%ss%%hsec% (3) Method 3 for /f %%a in ('powershell -Command "Get-Date -format yyyyMMdd_HHmmss"') do set datetime=%%a ECHO %datetime%
[ © 2008-2021 myfaqbase.com - A property of WPDC Consulting ]