Change date format dos batch file
Add a comment. Active Oldest Votes. Improve this answer. Compo Compo The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked You will find some information on the SET command on this link. REM Assumes times before 10am displayed padded with a space instead of a zero. I'm really new to batch files and this is my code!! It is kind of reused from others the question was to get a formatted timedate to use as filename.
The change to one Registry value for doing this is instantaneous temporary and trivial; it only lasts a few milliseconds before it is immediately reverted back. Double-click this batch file for an instant demo, Command Prompt window will pop up and display your timestamp.
Then double click it. If there is a 0 in the first 2 digits of the time, Windows ignores the rest of the file name of the LOG file. This bat file save as datetimestr.
To give proper credit, I merged the concepts from Peter Mortensen Jun 18 '14 at and opello Aug 25 '11 at You can write this much shorter, but this long version makes reading and understanding the code easy. I like the short version on top of The lorax, but for other language settings it might be slightly different. For example, in german language settings with natural date format: dd.
This is my 2 cents for a datetime string. I tried the accepted answer and it works pretty well. CS, and the missing 0 on the front was causing parsing problems before 10 am. If someone could please get me pointed in the right direction! Yes, it can be done via batch script.
Please post a sample of the code that you are trying to use. This will help us in making appropriate suggestions. Those lines just retrieve the current date and replace the slashes in it with dashes.
The result is saved in the datefix environment variable. Without seeing your actual code or getting a bit better description of what you're trying to do, suggestions are going to be difficult. You can change the system date format in the control panel, but I don't think it's possible to do so in a batch file. If your batch file is the one that is creating these files and naming them using the current date as part of the name, then something similar to the code you found could be inserted into the batch file.
To continue this discussion, please ask a new question. Get answers from your peers along with millions of IT pros who visit Spiceworks.
0コメント