Search code examples
delphidatetimedelphi-7

how to make delphi timetostr return military time


I'm working on a legacy Delphi 7 program. When I call

timetostr(now)

I get a time string in 12 hour format complete with the 'AM' or 'PM' trailer.

I looked in help doc in the Delphi 7 and did a search on the internet. The results were kind of vague.


Solution

  • According to Wikipedia Military Time is the regular 24 hour clock.

    In order to display that in Delphi you can use FormatTime. To be precise:

    FormatTime('hh:mm:ss', now)
    

    If you want milliseconds as well then

    FormatTime('hh:mm:ss.zzz', now)