If you're able to bring in an EXE, I recommend gdate.exe
from GNU CoreUtils for Windows). It can give the current date or the date of a file, in many different formats, and customizable. I use it to get me the last modified date-time of files that I can compare without any parsing (ie. local-independent), using the %s
(seconds since the epoch), optionally with %N
to get nano-second precision.
Some examples:
C:\>dir MyFile.txt
02/10/2021 10:54 PM 4 MyFile.txt
C:\>gdate -r MyFile.txt +%Y-%m-%d
2021-02-10
C:\>gdate -r MyFile.txt "+%Y-%m-%d %H:%M:%S"
2021-02-10 22:54:50
C:\>gdate -r MyFile.txt +%s
1613015690
C:\>gdate -r MyFile.txt +%s.%N
1613015690.093962600