How to Fetch the Date and Time using Batch Script

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video we are going to see how to fetch both date and time using batch script if I ask you just fetch me and show the date today's date if I ask you what is the current time can you show me using back script so in this video we are going to learn that so let's move on to our screen and let's get started couple of things first thing you have to know the specific commands Okay let me open the command prompt uh now let's see what is the command we have to use to fetch the date okay first we have to learn that then how to implement that in the basket I am going to show you okay so let me change the color clear it okay so the command is date okay if you write date generally what happens is give gives you the date and also gives you an option to enter the new date if you would like to change it if not if you simply hit on enter it'll go off same if you type time it gives you the time the current time and if you hit on enter it goes out getting it so now how do I Implement that in the basket we have to learn okay so let me show you let's write the first thing we'll write echo of I will turn off the capital letter Echo off okay all right now the very first thing that I will write is uh let's say I will use a set command okay so I'll say set and I will use any variable let's say a equals to and here I am going to say the date command you have to use so how to use it date is a command so all you have to do simply type percentage date percentage okay if you do this the value of date what you saw it in the command prompt the exact value will go to the variable a you can write any variable a b c d e f whatever you like you can write okay so here I will simply take a so a will have the value now how do I see this value simply I will say Echo percentage a for any any variable you will be writing this way right and then I will say a pause so let me save this and let me quickly run the script batch script and here it is okay so now if I run it you can see it says Tuesday 11 29 2022. getting it so we got the date now we got the date all right so uh now if I let me ask you a question what would happen if I write small a instead of capital A will it work or not let me save it now if I run this it still works right it doesn't matter great now I want time also so for time all I can do is simply say time here and if I save this and run the script what would happen I can see the time you can see the time right it's like night 30 you know 11 37 in the night getting it so the time also I can see it what if I would tell you I want both date and time together so how to get that it's quite simple all I have to do simply write a date here so I will write date okay and then I'll give it a space or whatever you like Dash whatever you like to give I'll give a user space here and I'll simply say time something like this okay so just by doing this now if I run the save and run it you would see both date and time has appeared in the format now you will have lot many questions Rakesh right a lot of questions would come to our mind one is how about I change the date format okay so let me close this yeah let me run that again okay so what if somebody says I want this is in month date and then year what if I want date then month then year somebody will say I want the year month and date right different different formats so how we can do that I will show you as we move forward but again this is the basic thing on how to fetch the date and time using basket so thank you guys so let's move on to our next topic
Info
Channel: Automate with Rakesh
Views: 5,315
Rating: undefined out of 5
Keywords: batch file, batch scripting, batch file command, batch file tutorial, batch script date, windows batch file date, date in batch script how to get current date in batch file, get-date in yyyymmdd format in windows batch file, windows batch file bat to get current date in mmddyyyy format, how to pass date parameter in batch file
Id: 0AuVpG8qZE4
Channel Id: undefined
Length: 4min 22sec (262 seconds)
Published: Wed Nov 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.