Batch file for one current date in text file

AMI - Jul 24, 2008 at 03:41 AM
 Robert - May 30, 2013 at 06:02 PM
I need a batch file to get the current date and time of my computer and put it in a text file every time I run it.But I need the most current date&time to replace the previous within the same text file, so that my file can have only one record, even if I run it multiple times.
I found this code:
echo %date% %time% >> log.txt

But this one just adds the next date under the previous one.
Your help would be greatly appreciated. Thanks in advance!

10 replies

Ola Ljunggren
Aug 22, 2008 at 02:33 AM

Remove one of the '>' and you have solved it.

It should look like this:
echo %date% %time% > log.txt

:) Ola

how do I write a script to find system date in the following format YYYYMMDD and use it to create folder using the same date.
these are some simple string manipulations to get Date, Time, and DOW if you would rather not use a FOR

REM - Create Date and Time strings
set Today=%date:~10,4%%date:~4,2%%date:~7,2%
set Now=%time:~0,2%%time:~3,2%%time:~6,2%
set DOW=%date:~0,3%
create one log.txt file on your c:\drive
say log.txt
and create one bat file ,open in edit mode and write the below line of code

echo the current date and tine is %time%%date%>>log.txt
Maram > abdullah
May 5, 2009 at 01:15 PM
I need program or procedure to extract the Gregorian date and the equevelent Hijri date from windows to the text file for 10 years .
waiting for your response .