Time in 24 hrs in batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sonalir
Posts: 4
Joined: 22 Aug 2012 04:08

Time in 24 hrs in batch file

#1 Post by sonalir » 22 Aug 2012 05:22

How to get Time in 24 hours timeline
eg:- 2:00 PM = 14:00

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Time in 24 hrs in batch file

#2 Post by foxidrive » 22 Aug 2012 05:30

Why?

Sometimes the reason can make a different approach work.

But you can change your regional settings for the time/date in control panel.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Time in 24 hrs in batch file

#3 Post by Squashman » 22 Aug 2012 06:00

My understanding was that the %TIME% variable was always 24 hour format the the TIME /T output only used the AM and PM.
I could be wrong though.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Time in 24 hrs in batch file

#4 Post by foxidrive » 22 Aug 2012 06:06

According to his previous thread it is the file last modified stamp that he's using.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Time in 24 hrs in batch file

#5 Post by Squashman » 22 Aug 2012 06:08

foxidrive wrote:According to his previous thread it is the file last modified stamp that he's using.

Yep. I just read that. Sorry.
Two options for that and you already pointed out one of them.
Either change the regional time settings in control panel or look at the AM/PM indicator and do the math!

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Time in 24 hrs in batch file

#6 Post by Ed Dyreen » 22 Aug 2012 14:52

Squashman wrote:the TIME /T output only used the AM and PM.
I guess that depends on regional settings, EU uses 24 hour format, always.

Code: Select all

>time /t
23:02

>dir
 De volumenaam van station C is ROOT-NTFS-X
 Het volumenummer is 4BB6-ACFF

 Map van C:\PROFSYS\ADMIN

20/08/2012  19:44    <DIR>          .

Post Reply