×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

batch files - date time

batch files - date time

batch files - date time

(OP)
I am trying to figure out how to generate a 24hour date time stamp on my backed up file?  I am using WinXP.

code:

rem Start1

for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k"-"%%i"-"%%j"-"

for /F "tokens=1,2,3 delims=:. " %%i in ('time /T') do set t=%%i%%j%%k

cd \
REM The next line copies the file
copy C:\just C:\bak\d%%t%-just.txt"

REM End1

end code:

This works but the time on it is a 12hour clock and has a or p for am and pm.

Please help!!!

RE: batch files - date time

(OP)
This is a control panel setting.  Regional settings and Select the time tab.

RE: batch files - date time

Hi Newbie,

Personally, I like parsing "ECHO.|TIME" because it gives seconds and milliseconds if you want them. It will also return 24hour time even if your time settings state 12hr time:

:: ---EXAMPLE.BAT----
@ECHO OFF
FOR /F "TOKENS=5-8 DELIMS=:. " %%F IN ('ECHO.^|TIME') DO (
 SET HR=%%F
 SET MN=%%G
 SET SC=%%H
 SET MS=%%I
)
ECHO Hours=%HR% / Mins=%MN% / Secs=%SC% / Millisec=%MS%
:: ---EXAMPLE.BAT----

pb

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close