realdate - get date/time for batch processing (DOS).
What is realdate?
realdate.com is a DOS executable file, runs under
any DOS version from the "real" DOS-es to the command prompts of the Windows
based operating systems.
It displays current date and/or time in any format you specify.
It's size is 1497 bytes [because of the lot of help text inside..., see /?]
It can get the operating system's time, or the time from the CMOS.
What to use it for? Ideas:
1) Generate a one line log entry with the date and/or time, independently from
the machine's operating system version and language.
Example: realdate >>c:\startup.log
2) Pass the date and/or time to a batch file variable. [examples]
Even though these are not impossible just by using batch tricks, it is not easy
to implement because of operating system language differences.
http://www.robvanderwoude.com/datetiment.html for excellent instructions on
How realdate[.com] works:
usage: realdate [/s="string to display first" [/f | /d | /t] /c /e /?]
/s - string within two separators (avoid "/"-s...)
/f - format string: default /f="CCYY.MM.DD hh:mm:ss"
/d - date only = /f="CCYYMMDD" and /s="" if not specified
/t - time only = /f="hhmmss" and /s="" if not specified
/c - use CMOS to get date and time (default: use DOS)
/e - add CR/LF (default: no EOL if /d, /t, /s or /f specified)
/? - display this help
defaults: /s="Current date/time: " /f="CCYY.MM.DD hh:mm:ss" /e
You can use any format specification you want, so let's say:
realdate /f="The century is CC, the year is YY, month=MM, day=DD"
will show up as: The century is 20, the year is 04, month=12, day=31" at 2004.12.31
You have to "watch your mouth", because these double letters will be converted
any place in the format specification, so:
realdate /f="SUCCESSFUL PADDING messed up..."
will show up as: "SU20ESSFUL PA31ING me56ed up..." at 2004.12.31 12:34:56
You can use /s for "noisy" text, you don't want to be converted. Then, without
using /e you can "echo" anything after.
You can use any string in place of the quotation marks, given they're the same,
and they're not occurring in the text, such as:
realdate /f='date is "YYMMDD" now'
realdate /f=$date is "YYMMDD", time=hh:mm'ss''now$
realdate /f=,This will be truncated after this comma, so this part won't be seen,
Actually, the last one will look like this: This will be truncated after this co34a
Why is /c?
/c is to get the date/time from the CMOS directly instead of using system calls.
This has not much use on GUI-d OS-es, but on DOS, when DOS time is (was) not let
to be refreshed properly, for example on some hardware when you start a NetWare
server and exit after sometime, DOS time is delayed and not the same as CMOS
time. CMOS time is the one you want to use in such cases.
To pass date to a variable in your batch file, you can use the following syntax under Windows NT 4.0 SP6 or above (Windows 2000, XP, ...):
for /f %%i in ('realdate.com /d') do (set logname=%%i)
rename backup.log %logname% etc...
The good old way will work under pure DOS, Windows 9x or anything less than Windows NT 4.0 SP6, and of course anything above it as well:
realdate /d /s="set logname=" >tmp.bat
Due to popular demand/requests: 64-bit version information
This utility was written in 1999, more than a decade and runs basically on
anything, from an XT to a P4 dual core, given that you use some 8-16-32 bit OS,
such as DOS or any kind of Windows capable of running a plain ".com" file.
But not on 64 bit - due to 64 bit Windows OS-es cannot/do not run ".com" files.
I was hoping that Microsoft eventually includes such a little thing into their
OS render my utility needless, but this day hasn't yet come...
So, there is no 64 bit version (or 32-bit) Windows command line ".exe" versions.
I would like to have one, but my "32/64-bit Windows programming" knowledges is
zero, so don't see too much chance on that.
If anyone is willing to rewrite it to a 32/64 bit Windows executable, then this
is welcome, here is the assembly source for the
If anyone starts "porting", please let me know, so can avoid different people
trying to achieve the same at the same time. Of course the resulting executable
(and source) would be welcomed to host here.
Since nowadays the size of the executable wouldn't really matter an other
approach could be to rewrite this in C++, Visual Basic or anything else which
can be compiled into an executable.
The "new" version should be at least compatible with the old switches, but there
are some other ideas/feature requests I got over the last years:
- ability to handle offset, eg. plus/minus time/date interval, so not just the
current date but day-1 or minus 1 hour could be "printed", such as an option
/o=-3600 or so
- printing out the number of the day of the week. Options for 0-6/1-7 and for
the day of the beginning of the week, eg. Monday or Sunday.
- printing out the name/abbreviation of the day. English could be a default,
but an ability to supply a string of choice, eg. with a: /w="H/K/Sz/Cs/P/Szo/V"
or similar "is a must" :-)
Freeware (if you cared...)
Automatic mail sending on Windows machines
www.robvanderwoude.com - Rob van der Woude's Scripting pages
Some words on date formats:
Personally, I found YYYYMMDD HHMMSS ("The ISO format",
to be the best in any logs or lognames because it can be easily sorted.
I also find this is the most logical way. Somebody else too, read a lot more at:
Comments, questions, suggestions on this page or on the program itself, to:
version - yyyy.mm.dd note...
v1.00 - 2004.07.26 First version
v1.01 - 2005.02.07 Added /c description
v1.02 - 2005.09.06 Some words on date formats...
v1.03 - 2010.02.09 64 bit version information