cmd: include date and time to filename

How can I get a filename YYYY.MM.DD_HH.MM.SS.7z? It should work with any regional settings!

The question is not duplicating 7-Zip CMD: Add current date to archive and include only the last modified folder in archive since I need seconds as well.

Regards,


Well while this question is technically a different question, the answer is essentially the same as that other question:

Echo "%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%

Since you specified that it must work with any regional settings though, that answer does not completely meet your needs. As far as I know, there is no way to meet your needs natively within cmd.exe. I would highly recommend doing this in powershell instead of cmd.