I have a batch script that starts with saving its start time for future use, which it does thusly:
set BATCHSTART=%TIME%
At the end of the batch, I'd like to re-convert it into a C# DateTime
, and I need to do it in a locale-independent way. So, how can I do this?
I tried using the registry values described here (HKCU\Control Panel\International
value sTimeFormat
), unfortunately it doesn't work: On the Windows 10 Server machine I tried it on, the registry says "HH:mm:ss"
, but %TIME%
returns "HH:mm:ss.ff"
instead (I also tried on a French Windows 10 machine, got the same registry value but %TIME
returned "HH:mm:ss,ff"
)
So, is there any way to fetch the real time format used by %TIME%
? Or failing that, to parse it in a way that won't run afoul of locale problems?
Or even another way to store the time during the execution of a batch file?