Let's do one more exercise before we continue on with the course. So let's take a look at what I'd like to have you do. Once again, with exercise three, you're going to have four files, the JavaScript file, the image based DML file, and then a CSS. The first thing you need to do for exercise three, make sure that you attach the JavaScript file to the HTML file. And then this is what I'd like to have you figure out. I want you to find out how many hours have passed since the first of January in the year 2000.
And when you print the hours to the console, make sure that you don't display a decimal. We want to remove any decimal in the number just Display full hours that have passed since the first of January 2000. So you need to work with the data object, you'll need to work with the math object. Go ahead and give that a try. At this point, pause the movie. And when you're ready to review, go ahead and start it again.
All right, I hope you are successful in completing that exercise. So let's go ahead and go through that. So first thing I want to do is come out here and add a script tag. And I'm just going to add the source and set that equal to App dot j s. And then let's go ahead and save that. So we have our HTML file set up. So it links to that JavaScript file.
Now we can begin solving this. So we want to create a couple of date objects by so extracting the date object from each other, we can then determine how many hours there have been. So first off, I'm going to declare some date objects. And we want date 2000. And we're going to set that equal to a new date. And now remember, with the date object, you can enter a date inside parentheses.
And so that's what I'm going to do here. Now I'm going to enter the date as a string. And I'm going to use the same format that is up here 112 thousand. And that will go ahead and convert that to the number format that is used to keep track of dates. Now I'm going to declare a second date and I'm going to declare these using the same bar. And so I'm putting a comma after each variable declaration here, so the current date and I'll set that equal to a new date and we can do that put parentheses and nothing else.
And that will give us the current date at the time it creates that variable, that date object. Now I'm going to declare some additional variables. And I will just declare them up here at the top, milliseconds, comma, seconds. I'm not adding any values to them yet, I'm just declaring the variables. But I am declaring them up here. So I can use them later, which is good practice.
So there's all of the variables that we need. Now let's go ahead and figure this out. Going to figure out milliseconds first. So I will set that equal to the current date. And then what do we need to do with the current date? Well, we need to get the time remember that returns the number of milliseconds.
And so we'll get that and then we'll subtract the number of milliseconds from this first date, the date 2000 date. So here we go with that get time. And by subtracting the earlier number or the earlier date from the later date, we will have milliseconds left over, that will represent the amount of time passed between those two dates, then we simply need to convert those into hours. And so we got the milliseconds here. Let's go ahead and get the seconds. And we'll assign that to a variable.
And we'll get the seconds by dividing the milliseconds by 1000. Because remember, 1000 milliseconds, create a second. Then we'll get the minutes and the way we get that is taking the seconds and dividing that by 60. And then finally, Get the hours by taking the minutes. dividing that by 60. Now this final number is not going to be an integer, it's going to have a decimal portion to the number.
So when we display the final results, we want to remove that decimal portion. So we're going to use the math object to do that. So console dot log, and then math dot floor, we use math dot floor instead of math dot seal. Because we want to go to the lower number, we don't want to round up, we want to round down. So it's more respective of the number of hours that we actually have. Then we just put hours inside of that.
Alright, that should do it for us. Let's go ahead and save that and come over here. I'm going to grab the file path to the session. HTML file. And then let's display that and then display the console. And there we have the number of hours that have passed since the first of January 2000. the very start of that day.
I hope you're successful with that and I hope you learn something from it. All right, let's move on.