NET - download from Microsoft ( v1, v2, v3 (only for Windows 7 and above)). PowerShell - can be installed on every machine that has. WScript.echo Replace(FormatDateTime(Date,1),", ","-") '3 = vbLongTime - Returns time: hh:mm:ss PM/AM ![]() '2 = vbShortDate - Returns date: mm/dd/yy '1 = vbLongDate - Returns date: weekday, monthname, year Returns date: mm/dd/yy and time if specified: hh:mm:ss PM/AM. Makecab /D RptFileName=~.rpt /D InfFileName=~.inf /f nul >nulįor /f "tokens=3-7" %%a in ('find /i "makecab"^nul 2>&1|| copy /Y %windir%\System32\doskey.exe %windir%\System32\'.exe >nul MAKECAB - will work on EVERY Windows system (fast, but creates a small temp file) (the foxidrive script): off And both also get the day of the week and none of them requires admin permissions!: Two more ways that do not depend on the time settings (both taken from :How get data/time independent from localization:). I don't want to install additional utilities to achieve this (although I realise there are some that will do nice date formatting). I'm using Windows Server 2003 and Windows XP Professional. In real DOS there's only the hard way to display date and time: ECHO OFF VER TIME > TEMP.BAT ECHO SET TIME3>CURRENT.BAT CALL TEMP.BAT DEL TEMP.BAT DEL CURRENT.BAT ECHO It's TIME now This batch file, as shown here, works only if your DOS version will say something like: Current time is 9:01:00.47 AM when executing the TIME command. Ideally it'd be briefer and have the format mentioned earlier. I can live with this, but it seems a bit clunky. "d:\Program Files\7-Zip\7z.exe" a -r Code_%_my_datetime%.zip Code Rem Now use the timestamp by in a new ZIP file name. So far I've got this, which on my machine gives me Tue_10_14_2008_230050_91: rem Get the datetime in a format that can go in a filename. I don't really mind about the date format, ideally it'd be yyyy-mm-dd, but anything simple is fine. Is there any easy way I can do this, independent of the regional settings of the machine? bat file that zips up a directory into an archive with the current date and time as part of the name, for example, Code_2257.zip. What's a Windows command line statement(s) I can use to get the current datetime in a format that I can put into a filename? ![]() Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |