0

I have written a batch script and i made a time-stamp variable for the folder's name. Everything was ok until yesterday, cause someone told me that the script is not working. I found that the error is on folder's name.

I use this command:

@set datetimef=%date:~0,2%_%date:~4,2%

and the results are the following:

My Computer: 26_10.

in not working Computer: MON_ 1.

Could someone explain me where is my error ?

pop rock
  • 517
  • 1
  • 6
  • 14
  • 5
    `%date%` value depends on the machine settings.To get indepence of local settings time stamps [check this](http://stackoverflow.com/a/19799236/388389) – npocmaka Oct 26 '15 at 11:59
  • 4
    Possible duplicate of [How to get current datetime on Windows command line, in a suitable format for using in a filename?](http://stackoverflow.com/questions/203090/how-to-get-current-datetime-on-windows-command-line-in-a-suitable-format-for-us) – Mofi Oct 26 '15 at 12:08
  • @Mofi It's not duplicated because i asked why the time stamp is not the same in all PCs and the answer was that `%date%` value depends on the machine settings. The other users asked how to get current datetime and i don't asked that, so simple. Thank you – pop rock Oct 28 '15 at 12:29
  • @poprock Well, `Unusual error with date in batch script` is not really a question. Your code line does not contain any error. Searching on Stack Overflow with [\[batch-file\] date](http://stackoverflow.com/search?q=%5Bbatch-file%5D+date) returns more than 4000 posts and in many of them is written that date format of variable __DATE__ depends on Windows region and language settings and `wmic` offers a method to get date and time in a region independent format. For a comprehensive answer on usual date/time processing issues read [this answer](http://stackoverflow.com/a/32670346/3074564). – Mofi Oct 29 '15 at 08:26

0 Answers0