Welcome! Today we're going to go over a really basic Linux command line tool and it is "date".

So the date command, as you might expect, returns the actual time and date that is right now.

Now, that isn't particularly interesting, however, as you probably what the date was anyways.

However, again, as I've said in a couple other previous videos, this is super useful when your scripting.

So if I were to script out "This script was written on `date`.

" It will print out "The script was written on Wednesday, March 8.

" and the exact time, the time zone, and year.

However I think today is a good video to start looking at what some people call flags and what some people call switches in Linux.

And that is, the actual command – so I'm just gonna clear this – date and then you put a hyphen and then something else.

In this case we start out with, if you do a "-d" and then you actually give it a date – so 03/03/03, sort of a weird date – it'll pop out Monday, March 3rd, 2003.

OK? So if you wanted to put timestamp on something – a specific time stamp that was different than the actual time that you're using right now, you can use this "-d" switch or flag, and give it an argument and "boom" – there's your output.

That may not be the most useful one, but it is a a decent one.

Here's another one that's pretty common: If you do a "-I" you get the date outputted in just 2017-03-08.

That might be useful to you depending on the output you need.

You might also rather this one which is "-R", and that gives you a full read-out like "Wednesday, March 8th, 2017.

" OK.

Let's see some other ones.

Oh this is a really useful one.

If you're working with someone who is not in the same time zone as you if you put a "-u" on your date command, it gives you the universal timestampm, and if everybody who's working on the project uses the "-u", then you know what time that you're doing things, compared to someone who might be two times of those away.

Let's say, you know, one's in New York and one's in LA (not that I live anywhere near either one of those), but, you know, if you live in time zones across the continent or even cross-continents, you know, two different continents, if you use UTC then you're going to have the same timestamp.

You'll be able to use and compare, you know, who's doing this that this time, who's doing this at that time.

Of course, with all, virtually all, Linux commands – I'm just going to clear the screen here – with all, virtually all, Linux commands you can do a version, which has "- – version" literally the word version, and it gives you some details about which version you're using.

You can use this to make sure that you're up to date, and you can also, if you're interested, look at who wrote this little of applet, then go from there.

Oh, one other one that I really wanted to show you that I thought was pretty useful is – I'm just going to do an "ls", just so I can see the name of my file, OK its right there – so if you go "date" and you go "-r", with an "-r" flag, and then you type in the folder, sorry, the file that you're looking for, then it gives you the date that it was last updated.

So if you're, that's a really common tool in computing – you're looking for, or which, sorry, when was this file last modified, you know, when was this last changed.

So if you use the "-r" and then just the name of the file, then, immediately you get those details.

So that's a pretty useful tool.

So "date" is useful – is useful for scripting, and I just wanted to go over some flagging, just so, or switches, depends on your – they mean the same thing.

Just that you're familiar, because as we get into more complex commands this is going to be a really common thing, to use a switch, to use a flag.

So, there you go.

Sorry I'm a little stuffed up still, got the flu, but it is what it is.

We have to move forward.

Thanks for watching, and keep watching, there's going to be lots more coming.

I really appreciate your time.

Have a good day!.

(Visited 15 times, 1 visits today)
adminTips-,/,command,commands,date,FLAGS,Linux,SWITCHES,Terminal
Welcome! Today we're going to go over a really basic Linux command line tool and it is "date".So the date command, as you might expect, returns the actual time and date that is right now.Now, that isn't particularly interesting, however, as you probably what the date was anyways.However,...

Do you want to be notified about new DBA updates, releases, jobs and free tips? Join our email newsletter. It's fast and easy. You will be among the first to know about hot new DBA updates and stuff, it will help you enhance your DBA skills.
We take your privacy very seriously