The is very precise and accurate. I think this is the best answer for the question because you don't need any adjustments to use it as a file name. Thanks for sharing! Perfect, this is the best solution for me as calling PS will result in the appearance of the cmd text to go funny looking.
Unfortunately this is not immune to regional settings, but it does what you want. Mark Ransom Mark Ransom k 40 40 gold badges silver badges bronze badges. Mark - Found Cmd. Not finding that info any longer in the Wikipedia article. Would like to find an authoritative reference from Microsoft.
This is IMHO the easiest solution if you want to use the date and time just for logging purposes J c J c 6, 3 3 gold badges 28 28 silver badges 29 29 bronze badges. Jeff Atwood DigiP DigiP 1 1 silver badge 2 2 bronze badges. Yordan Georgiev Yordan Georgiev 4, 1 1 gold badge 45 45 silver badges 52 52 bronze badges. Matthew Johnson Matthew Johnson 1 1 silver badge 2 2 bronze badges. Is there a way to get the time in a 12 hour format and also to display AM or PM information?
Just use this line: PowerShell -Command "get-date". JonathanDavidArndt 2, 13 13 gold badges 33 33 silver badges 45 45 bronze badges. John Langstaff John Langstaff 8 8 silver badges 9 9 bronze badges. Rainabba, that is exactly the error you get when that command is issued from the CMD line. However, " from within a batch file ", the command returns " ". And here is a similar batch-file for the time portion. Any help would be very appreciated. Please take a look at the link for the details stackoverflow.
Ask a new question about that. I've never used forfiles. Community Bot 1 1 1 silver badge. Some do use years first, or lack leading zeroes; see Wikipedia's Date format by country.
The French might use jj-mm-aaaa for jour, mois, annee? Germans tt. But then: I guess in most countries only a few languages are used. Good enough for me. As an aside: another version in Hidden features of Windows batch files is less perfect needs the fix for the Dutch jj , and does not enforce a 4 digit year , but uses shift to discard the day like Mon or ma. Just different. It breaks on a German system. Year and month work, but day fails because "day" starts with a "T" in German "Tag" , not a "d".
Opening a new command prompt fixes that. So, you'll still need to cut off or otherwise deal with the "Tue" and the space character. Hi micahwittman. I have tried "forfiles" command but to no avail. Tomalak Tomalak k 64 64 gold badges silver badges bronze badges. KChiki KChiki 51 1 1 silver badge 1 1 bronze badge. Put it in your Windows system32 folder. It has a lot of "date output" options. For help, use DateFormat. Sally Sally 95 2 2 silver badges 4 4 bronze badges.
Thanks, although this question is specifically for doing it without downloading additional tools. Gerhard Gerhard Adolfo Adolfo 2 2 silver badges 5 5 bronze badges. Put it inside bin folder next to the batch script. References This awesome answer that I build upon. Brendan Harris Brendan Harris 31 3 3 bronze badges. It seems that this comes with the regional issue - this doesn't work in all English machines.
Not surprised, SteveFest. If it were possible to temporarily set the locale, that might help to provide a global solution, but it seems it's necessary to the know the region in advance. Is your locale en-US or en-SomewhereElse? I'm super busy, but I'll try to update my answer to illustrate. I may be foolishly assuming zh-HK prints digits at fixed offsets. But please note one thing: the date time format can be changed per machine. Thanks SteveFest, I'll follow up within a few weeks. The program takes time to run, but maybe the locale result could be cached and subsequently used to index a timestamp format.
Burgi 7 7 silver badges 24 24 bronze badges. Frizz Frizz 1, 13 13 silver badges 19 19 bronze badges. And again. It's nice that it works on your machine, but you missed the point independent of the regional settings of the machine — jeb. Active Topics in this Category. Add to My Favorites. Printer Friendly Format. Manage Topic. Manage Content in This Topic. Manage Members. Online Now. Control Panel. Posts: 16 Registered: November 17, Tony A Expert.
Hide Post. Show Post. Ignored post by alandool posted December 20, AM. Powered by Social Strata. Is it possible to get date created? Hope this helps. Eddie Paz Eddie Paz 1, 15 15 silver badges 11 11 bronze badges. Ayush Pant Ayush Pant 1 1 silver badge 8 8 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
Post as a guest Name. Email Required, but never shown. 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 Related
0コメント