 Hello and welcome! Today we are going to just look at the date command. We've used it before, I'm sure, but I'm going to be writing some scripts using it in the next couple of days, probably, so I thought that I would go over some basic functionality of it. Now, you probably know if you type date. It gives you the date, day of the week, the month, day of the month, hours, minutes, seconds, your time zone, and the year. But the date command can actually do a whole lot more, not only output things in different formats, your date and time in different formats, it can also do calculations for you for between dates and stuff like that, or get certain dates, the date of certain things in the future and past. Well, let's just look at it. So, one that I use a lot is date plus percent s. And what that gives us is our epoch time, or UNIX time stamp. And that's the number of seconds since the midnight, January 1st, 1971? I don't even remember. But it's the number of seconds, there's no... It makes it very easy if you want to do calculations. We've done this in past with timers. It's the number of seconds, so it's like, how long since I ran that command? If I run again, now I can subtract the second number, the first number from the second number, and that's how many seconds it's been, and then you can convert that into minutes, days, weeks, months, whatever you want, because you can do the math on the number of seconds, where you're trying to calculate what day it is can be difficult because there's different number of days in a month, is it leap year, blah blah blah, but if you're trying to get how much time has passed, time stamp like this is very useful as we've talked about in the past. But basically you do date plus, and then you percent and a letter, and it will output something different. Like, if I was to do date plus percent with an M like this, it says 10 because it's October right now, when I'm recording this, it's the tenth month. If I do a capital M, it says 05 because if you look at the time right now, it's five minutes after 10. If you do H, that's going to give you the hours here, but you can also put these together. So like, D is the day of the month, capital Y is the year. Lowercase Y is the year, but in a two digit format. So if I wanted to do, make the date look like this, 10, 16, 2018, I can do that. So I just say date plus percent, and then I say M, lowercase M for the month, and I'll do a slash, and I'll do percent D for the day, slash percent, and I can do a capital Y if I want 2018, lowercase Y if I want just 18. If you want to do it depending on what country you're in, you probably do it a different way, like so you can do the day, then the month, then the year, which yes, I admit makes sense, but really I think it makes more sense if we did year month day, if you really want to get technical about it. Anyway, clear the screen here. Other options are, if I did a capital F here, it does it similar to what I just said. Actually it is what I just said, but they use dashes. So if you wanted that but you wanted slashes instead of dashes, as far as I know you'd have to manually do slash percent month percent day. Is that right? Yeah, so F is a format similar to what I was talking about, but maybe you want different delimiters or what you want to call them in between the numbers. So that's some things. So if you want to do another option that is plus percent A, that's the day of the week. I could do plus percent capital A and instead of the short little three letters, it gives me the full name. And of course you can do this to check stuff. If you're a script running, you want to do it something different on Monday than Tuesday, you can check this. You run that command and compare it to, does it say it's Tuesday? Does it say it's Monday? If so, do this with basic if then statements. You can also do time stamps. So I can do plus percent and I can do a capital H is the hour. Capital M is the minutes and capital S yeah, capital S is the seconds. And I am looking at notes, which we'll talk about here in a moment. H plus, or not plus, but we'll do like this. So we're going to do A time percent M colon percent S. And no, not lowercase S, capital S as we talked about. Lowercase S is seconds of epoch time. And if I run it again, you can see now it's changed. So that's that. If we do man date, we can go in here and scroll down and they have everything listed. We have day of the week in numbers where zero is Sunday. You can have week number of the year. So there's 53 weeks in a year. You can figure out what week of the year it is. So months, minutes. Oh, if you want to put a new line, I didn't even know you could do that. I would have done backslash M. Let's see, let's give that a try. Let's say I wanted the seconds on a new line. Does this work? Nope, it doesn't. So they said percent N and it put the seconds on a new line. So I could do something. I wonder, will this work? I go hours percent N minutes percent N seconds percent N. Oh, no, I don't want the percent on there. Well, that's pretty cool. I didn't even know you could do that. So you learn something new every day. So yeah, lots of, I mean the man file only has a few options other than the formatting. Most of that man file is formatting. So there you go. Go ahead and check that out. We'll get this a little bit more in the next video. I do thank you for watching. Please visit filmsbychrist.com. That's Chris the K. There's a link in the description. And as always, I hope that you have a great day.