 Today, we're going to figure out how to tell how much time has elapsed between two dates. If you enjoy my tutorials and would like to see more, please think about contributing to my Patreon account at patreon.com forward slash metalx1000. So let's say you have two dates and you want to find out how many days has passed between the two of them. Well, let's first off look at the date command and what can be done with it. So a lot can be done with it, more than we're going to look at today, but if you just type date in your shell and hit enter, it's going to tell you today's date and time. Right now, while I'm recording this, it's Saturday, August 23rd. It's 1400 hours, three past that, 26 seconds past that, and it is 2014. So it's 2.03pm, to put it simply. Okay, so another thing you can do to get that output of a time, you can get displayed in different formats, and one of those formats is going to be important for today. We're going to say it's plus percent s, and when we hit that, you can see it gives us this big old number. What this is, it's the number of seconds that has passed since midnight on January 1st, 1970. So if I run this again, you can see it's been a few seconds, and if I run it every second or so, it adds one second to it. It's been about four seconds since I ran it last. Yep, there we go. Perfect. So now we know that we can convert today's date into seconds like that. Can we convert other dates that have passed, or ones in the future? Well, sure we can. I'm going to use control L to clear that, and I'm going to use the date command, and I'm going to say plus percent s, just like we did before. My video finished converting, okay. And what we're going to do now is say dash d, and we're going to give it a date, and we're going to give it in this format. We're going to say the year, so we'll say 2014. The month we'll say 01 for January, and I'll say January 5th. Okay, so if I hit enter now, you can see we get the number of seconds since midnight, January 1st, 1970, to that date. If I was to go and put in another date, let's say January 6th, so we'll say 2014. We say January and 06, before the sixth day. You can see that it is a slightly higher number. So what we're going to do here is how many seconds are in a day? Now, there's two ways we can figure this out. We can say echo, and we can say, well, there's 60 seconds in a minute. We're going to multiply that by 60 minutes in an hour, and we're going to multiply that by 24 hours a day. We're going to pipe that into our BCR calculator here, and we get 86,400. So we can assume right here that there's 86,400 seconds in a day. That's every day. Of course, another way we could figure this out is we can say echo, and we can say inside parentheses here that number, and we can say minus in parentheses the first date and pipe that into BC. And if I did this correctly, oh, I'm sorry, should be dollar signs here. I don't know why I missed that. So what we're saying is run this command, and since we're putting in parentheses with a dollar sign, it's going to put the output of that command. So basically, it's going to put this number, and do the same for this date. And there we go. We can see that, yeah, the dates are adding up properly when we're using the date command, because according to this, from one date to the next, 86,400 seconds has passed, and when we did our math earlier, it matched as well. So we can do the same thing for different dates. So here, we did from the fifth to the sixth, obviously, using the higher number first. Well, how many days passed from the second to the sixth? Well, we get, again, in seconds. So how do we figure this out in days? Well, if we know that there's 86,400 seconds a day, we can take this number and divide it by that. And that did not work, because it's dividing first. Right. We have to put another parentheses here, and parentheses here, and might have to put that in quotations. There we go. Four days have passed with a few little mistakes there. So why did we have to put up these things? OK, anytime you use the echo command, you should put things in quotations. I don't know why I wasn't earlier, but I should have been. But if you do basic math, please excuse my dear Aunt Sally, that you're going to do stuff in parentheses first. If not, division comes before subtraction, which means it was doing the division and then subtracting that number from the other. That's why we got this number before, and that's not right. So what we're doing here, and let me clear the screen just to simplify it so there's not other stuff on the screen, we're saying, OK, get the number of seconds for this date and get the number of seconds for this date and subtract them from each other. We're doing that first because they're inside parentheses. And then after that, that's going to give us the number of days in seconds between the two. So to get the number of days rather than the number of seconds, because we're smart and we know that 86,400 seconds are in a day, we can divide by that number. And from the second to the sixth of January on 2014, there are four days. And you can put in whatever you want here. Let's say we wanted to figure out from 2001, and we'll say February 2, 2001 to January 16th. Sorry, January 6, 2016. Well, we get a lot of days there. And again, if it's that large, then you can do more math after that to figure out the number of years and days. But we're going to stick with days for right now, because I don't want this tutorial to go on too long. I'm basically showing you the basic concept of how to do this, and now it's up to you to figure out the right math equations for the rest. You're going to have to do some division based on days and take the remainders and get the days, put that with the years, you know what I'm saying. So anyway, from February 2, 2001 to January 6, 2016, 5,451 days will have passed. So I hope you found this tutorial useful. You can count down till Christmas or whatever you want to count down to. You can do a second counter, a minute counter, a day counter, a year counter. Well, if you count down to Christmas, that wouldn't make sense. But just by changing what you're dividing by, and I hope that you found this tutorial useful. And as always, I hope that you have a great day. Please visit my website, filmsbychrist.com. That's Chris at the K. There should be a link in the description. And again, have a great day. This is bad. You're bad. No, I'm not going to ask you to see. Obviously, I'm just bad. More than I even brought in your seat. My point, though, is I would like to take a moment to thank the following patrons who made this video possible by supporting me over at patreon.com forward slash middlex1000. The server's only giving you this much on downloading a file. You could do four connections and speed up your download. Another option would be as sometimes servers have mirrored servers. So even though you have that original server, you may have another server here.