Hello and welcome.
In this fit you.
I'm going to add some javascript code that will enable the clock to display.
So inside my text had it all here.
Just want to make sure I've got my hastier Mail see if we click on the hastier much fun now you would
not see anything to find double-click and just click on the file.
You can see just got a blank space so nothing will get displayed on till the javascript has been written.
Some just can open up the javascript file so click on this my script jirus and I will just collapse
this index started to email to that have some space and also drag this in a bit to create more space.
So the first and I want to do is had a function and method the method I'm going to add it's called the
set interval method.
So I had read a method called set interval and also added a function set interval method is used to
call a function that value it's an expression at a specified interval.
The interval is usually set in many seconds to what they set interval to.
It all continue to run.
This is what will make the clock continue to tick a thousand milliseconds is equivalent to 1 second
set interval.
Third require as the function that will be executed.
Okay so in between this curly braces here I am going to add some code that to enable the clock to be
displayed and then said I want to do inside this function.
Here is create a new variable and set that variable to quote to a new date object Date object is a data
type that is built into the javascript object on language so to create a new date object you use the
new date command to create an object.
So let me add the code so you can see.
So I've created a variable here called current time and I said that to a new date object and then extend
I want to do is quote some variables that will store me hours minutes and seconds.
So I've now added the three variables created a variable called hours minutes and seconds.
I've said that to you course to this current time variable and Tash get hours method to get hours metabolically
warm.
Get the hours that is returned they get minutes metod will returned in minutes that's returned and they
get seconds method will return the seconds returned.
Also I want to be able to specify based on the time if it's P. M. or M saw to do that.
I need to create a variable that will store the value.
So I'm going to create on another variable that will store a value for him sough quoted a variable quod
period and I've set that to a value of a m.
The next thing I want to do I want to use a conditional statement in order to determine if it's in or
P. M..
So this is a condition here.
I have added some checking for some condition the same if the hours variable.
This hours here is great and down or equal to 12.
Then this variable here will be regarded as P. M..
I added some more conditions here so from here to here.
So here on line 11 saying if the hours variable hours here is less than 12 I'm setting the hours to
equal to the hours minus 12.
Here again chaykin give the seconds variable is less than 10 AM set in the second clearable to eat.
Was 2 0 plus the seconds.
This one also.
I'm checking the minutes variable variable here is less than 10 AM set in the minutes variable took
of course to zero.
Plus the minutes.
Next since I want to do now is create a variable that will store all these values in order to display
the clock.
So I've created a variable here on line 20 chord clock time and I've set that to your Kwas to the hours
variable which is this variable here.
Plus this here's just great innerspace Plus the minutes variable Plus the second variable Plus the peer
to peer a.
Basically it would tell you if it's an M or p. m..
Based on these conditions this could see a bizarrely used to create spaces between the hours the minutes
seconds and the period period represents the variable here.
So depending on this condition it will determine if it's m or P. M. The next someone to do is quit a
variable that will display the clock.
So here I caught an idea here chord clock.
So this is where I want to call the clock to be displayed inside this variable.
Inside this I see chord clock which is a div so I need to create a variable that will achieve that.
So I have now created a variable on line 21 called clock an offset that took it was to document.
Don't get telamon by Dean method this method here will return the I.D. element which is specified here.
And this clock idea.
Here is the irony of this db here.
That's what I am targeting too.
Will return that does what this says and here reference seem.
This variable here.
Chord clock and I am changing in a text to the value of the clock time to the variable here and well
a variable we call clock time we should display B hours the minutes the seconds and the periodicities
a.m. or p.m..
So thats what Im doing here.
I am changing the inner text of this idea here called clock change in a use in this property.
In a text to this variable so this will make it display a clock.
Basically this will reference all these values from your current computer.
So whatever clock your computer is showing that square is going to pick up the time from here you got
a time right here.
This is only time in milliseconds.
This set in tabar function also runs every time this milliseconds enables the clock tick.
So that means the clock will be ticking every one second.
That's what this one puzzle for is.
It means the clock would take every millisecond which is equivalent to one second.
So if I save that now we should see some activity.
MBA browser.
All right so this is it you can see is showing me my current time and it tells you it is actually p.
m..
At the moment.
So in the nakes feeding one as some see access to make this look much more pronounced and presentable.
Thanks very much for watching and by phone now.