(E-Mail Removed) wrote:
> This is a little diddy i use in my back up scripts for time stamps, it
> is very configurable on how you wanna represent time.
> Note: if you are testing this in a CMD window change %% to % if this is
> in a batch script it runs perfectly.
>
> for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set dt=(%%i)
> %%l.%%j.%%k
> for /f "Tokens=1" %%i in ('time /t') do set tm=.%%i
> set tm=%tm::=.%
> set dtt=%dt%%tm%
> echo %dtt% >> file.txt
>
This 'time' value is not very useful because you are not accounting for
'AM' or 'PM'. To just have the time displayed as '03.22' doesn't tell
me if it was morning or afternoon. If you wanted to drop the 'PM',
then you should add 12 to the hour value to get a meaningful log entry.
--
Phil Robyn [Microsoft MVP]
University of California, Berkeley