Regional Independent date time batch job


Got pissed off because your batch file has to know the current date and time and depending on the user or machine logged on you don’t get the same result? Let’s use today snippet: regional independent date time batch job.

In the past, you used:

  • date /t
  • time /t

But did you know there was a Win32_LocalTime which exposes dateĀ  parts and time parts as properties?

Don’t know how to use that class? Look at that snippet:

You may change the format of date stored in today and the time in now by changing the order of the tokens’ variables.

Feel free to replace WIn32_LocalTime by Win32_UTCTime if you need to be time zone independent

Leave a comment

Your email address will not be published. Required fields are marked *