Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 7zip CMD: Add current date to archive & include only last modified folder in archive since I need seconds as well.


share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer


echo "%DATE:~10,4%.%DATE:~7,2%.%DATE:~4,2%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%.7z"


share|improve this answer
Outputs: .01.5/_22.11.58.7z where I live - %Date returns the system date formatted according to the regional settings, so the position of day, month or year are not always the same. – Peter Hahndorf May 27 '12 at 20:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.