Exercise 4: Clock using JavaScript | JavaScript Tutorial in Hindi #51

Exercise 4: Clock using JavaScript | JavaScript Tutorial in Hindi #51

CodeWithHarry

1 год назад

120,163 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Harsh Paradkar
Harsh Paradkar - 05.10.2023 21:21

Sir, maja aa gaya ye wala project bana ke, I even added a stopwatch and timer and wrote the entire logic from scratch. It was a good revision of everything you taught it's only halfway through the course and I already have learnt so much. A few months ago I was losing confidence because I was not able to understand the code at my job but this course has helped me tremendously. Also I never commented on your videos but Your OOP and DSA course helped me get my first job and I realised I have never thanked you. Thank you so much I don't know how should I let this known to you, but you are directly responsible for everything I have learned the field of programming and your videos have been source of all my programming related knowledge. You have transformed this scared kid into a savant of Computer programming fundamentals, I owe every bit of my success to you.

Now and always you have kept learning new topics very easy and comfortable and I thank you for all the efforts you make, it is making impact and changing thousands of lives just like mine. All I mean to say is. Thanks for Everything @Harry Sir

Ответить
sujit mishra
sujit mishra - 19.09.2023 16:27

sir agar kabhi viman nagar aaya toh milke jaunga

Ответить
Dhruv Dhameliya
Dhruv Dhameliya - 19.09.2023 12:57

<div class="container">
<div class="full">
<div class="time">
<span class="digit" id="hours">00 </span>
<!-- <span class="text">hours</span> -->
<span class="digit" id="minutes">00 </span>
<!-- <span class="text">minutes</span> -->
<span class="digit" id="seconds">00 </span>
<!-- <span class="text">seconds</span> -->
<span class="digit" id="count">00</span>
<!-- <span class="text">count</span> -->
</div>
<!-- for create a button -->
<div class="btn-container">
<button class="btn" id="start" onclick="start()">start</button>
<button class="btn" id="stop" onclick="stop()">stop</button>
<button class="btn" id="reset" onclick="reset()">reset</button>
</div>
</div>
</div>
<!-- start javascript -->
<script>
let hr = 0;
let min = 0;
let sec = 0;
let count = 0;

// it's for deided now timer is start or false
let timer = false;

function start(){
// now timer is start when we are click start.
timer = true;
stopWatch();
}
function stop(){
timer = false;
}
function reset(){
timer = false;
// all should be 0
hr = 0;
min = 0;
sec = 0;
count = 0;

document.getElementById("hours").innerHTML = "00";
document.getElementById("minutes").innerHTML = "00";
document.getElementById("seconds").innerHTML = "00";
document.getElementById("count").innerHTML = "00";
}

// actual function
function stopWatch() {
// first cheack time is true
if(timer == true){
count = count + 1; //count++

if(count == 100){
sec = sec + 1;
count = 0;
}

if(sec == 60){
min = min + 1;
sec = 0;
}

if(min == 60){
hr = hr + 1;
min = 0;
sec = 0;
}
// for add our strind like "0"
let hrString = hr;
let minString = min;
let secString = sec;
let countString = count;

if(hr < 10){
hrString = "0" + hrString;
}
if(min < 10){
minString = "0" + minString;
}
if(sec < 10){
secString = "0" + secString;
}
if(count < 10){
countString = "0" + countString;
}
document.getElementById("hours").innerHTML = hrString;
document.getElementById("minutes").innerHTML = minString;
document.getElementById("seconds").innerHTML = secString;
document.getElementById("count").innerHTML = countString;

setTimeout("stopWatch()" , 10)
}
}
</script>

Ответить
sourav saha
sourav saha - 25.08.2023 08:06

let c = document.getElementById("c")
setInterval(clock = ()=>{
let D = new Date()
let hour = D.getHours()
let minute = D.getMinutes()
let second = D.getSeconds()
let miliS = D.getMilliseconds()
let day = D.getDate()
let month = D.getMinutes()
let year = D.getFullYear
// console.log(hour,minute,second)
c.innerHTML = `${hour} : ${minute} : ${second}`
},1000)

let dayy = document.getElementById("day")
setInterval(clock = ()=>{
let D = new Date()
// let hour = D.getHours()
// let minute = D.getMinutes()
// let second = D.getSeconds()
// let miliS = D.getMilliseconds()
let day = D.getDate()
let month = D.getMinutes()
let year = D.getFullYear()
// console.log(hour,minute,second)
dayy.innerHTML = `${day} : ${month} : ${year}`
},1000)

// setInterval(clock = ()=>{
// let D = new Date()
// let hour = D.getHours()
// let minute = D.getMinutes()
// let second = D.getSeconds()
// let miliS = D.getMilliseconds()
// let day = D.getDate()
// let month = D.getMinutes()
// let year = D.getFullYear
// console.log(hour,minute,second)
// },1000)
// console.log(hour,minute,second,miliS)

Ответить
sourav saha
sourav saha - 25.08.2023 08:06

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="clock.css">
<title>This is a Clock</title>
</head>
<body>
<div class="clock" ><h1 id="headclock">CLOCK</h1>
<br><b><p>Hours Minutes Second</p></b>
<h1><section id="c" ></section></h1>
<br><b><big><pre>Day Month Year</pre></big></b>
<h1><section id="day"></section></h1>
</div>
<script src="clock.js"></script>
</body>
</html>

Ответить
kyle crane
kyle crane - 20.08.2023 20:09

Magar kyu 😢😢

Ответить
Thomas Shelby
Thomas Shelby - 15.07.2023 02:16

a = new Date()
h = a.getHours()
m = a.getMinutes()
s = a.getSeconds()
let scounter = s
let mcounter = m
let hcounter = h
let intervalid = setInterval(function() {
scounter++
if (scounter == 60) {
scounter = 1
mcounter++
}
if (mcounter == 60) {
mcounter = 0
hcounter++
}
if (hcounter == 25) {
hcounter = 1
}

let x = document.getElementById("time")
x.innerHTML = (hcounter + ":" + mcounter + ":" + scounter)

}, 1000)

Ответить
Sinmbf Lost
Sinmbf Lost - 31.05.2023 16:23

let container = document.getElementById("container");
let timerID = setInterval(function() {
let date = new Date();
let hrs = date.getHours();
let min = date.getMinutes();
let sec = date.getSeconds();
let am_pm = "AM";
while (hrs > 12) {
hrs -= 12;
am_pm = "PM"
container.innerHTML = `<center>${hrs} : ${min} : ${sec} ${am_pm}</center>`;
// container.innerText=hrs+":"+min+":"+sec+am_pm;
}
}, 1000)

Ответить
Gausiya Khan
Gausiya Khan - 19.04.2023 23:37

Bhai plz java using DSA pr current course liye placement keliye
..plzzzz bhai 🙏🙏🙏🙏

Ответить
Hassan Mustafa
Hassan Mustafa - 10.03.2023 00:53

what is the problem i am facing?
i'm not getting the value of console.log on browser can someone tell me whats the fix?

Ответить
Arsalan Rather
Arsalan Rather - 03.03.2023 07:47

Ui?🙂🔪

Ответить
Vaibhavsinh Bihola
Vaibhavsinh Bihola - 27.02.2023 19:52

let time = () => {
let a = new Date();
let h = a.getHours();
let m = a.getMinutes();
let s = a.getSeconds();
document.getElementById("time").innerHTML = `${h}:{m}:{s}`;
}

setInterval(time,1000);

Ответить
𝕀 𝔸𝕄 ℝ𝕌𝔻ℝ𝔸
𝕀 𝔸𝕄 ℝ𝕌𝔻ℝ𝔸 - 24.02.2023 16:06

let clock=document.getElementById('clock')

setInterval(()=>{
clock.innerHTML=new Date()
},1000)

Ответить
Mohammad Raza
Mohammad Raza - 28.01.2023 13:40

let time = ()=>{
let d = new Date()
let h = d.getHours()
let m = d.getMinutes()
let sec = d.getSeconds()
var clock1 = document.getElementById("clock");
clock1.innerText = h + ":" + m + " " + sec;
}
setInterval(time,1000);

Ответить
Tech Nikal problem
Tech Nikal problem - 01.01.2023 01:46

Thank you sir for creating this video!

Ответить
jay patil
jay patil - 18.12.2022 16:51

Autowrite kaise hota hai isme..please tell

Ответить
my account
my account - 16.12.2022 16:44

let clock = document.getElementById('clock')
let day = document.getElementById('day')
// console.log(clockdivbox)
setInterval(() => {

let time = new Date()
let h = time.getHours()
let m = time.getMinutes()
let s = time.getSeconds()
let date = time.getDate()
let year = time.getFullYear()
let month = time.getMonth()
if (month ==0) {
month = 'january'
}
else if(month == 1 ){
month = 'february'
}
else if(month == 2 ){
month = 'march'
}
else if(month == 3 ){
month = 'april'
}
else if(month == 4 ){
month = 'may'
}
else if(month == 5 ){
month = 'june'
}
else if(month == 6 ){
month = 'july'
}
else if(month == 7 ){
month = 'agust'
}
else if(month == 8 ){
month = 'september'
}
else if(month == 9 ){
month = 'octumber'
}
else if(month == 10 ){
month =' november'
}
else if(month == 11 ){
month = 'december'
}
// console.log(h, m, s, date)
let timezone = h > 12 ? 'PM' : 'AM'

// set hours
h = h > 12 ? h = h - 12 : h = h
h = h == 12 ? h = 0 : h = h
//set minutes
m = m < 10 ? 0 + `${m}` : m = m
// console.log(m)
// set second
s = s < 10 ? 0 + `${s}` : s = s
// console.log(h, m, s, date)
clock.innerHTML = `${h} : ${m} : ${s} ${timezone}`
day.innerHTML = `${date} ${month} ${year}`
}, 1000);

Ответить
Oqant0
Oqant0 - 11.11.2022 13:51

lecture 51 done (11.11.22)

Ответить
Vishesh Pandey
Vishesh Pandey - 10.10.2022 18:25

Chaliye shuru karte hai was epic XD

Ответить
Entertainment videos
Entertainment videos - 01.10.2022 16:23

Bhai upload next video
Waiting. . .

Ответить
code with shubh
code with shubh - 01.10.2022 16:17

I'm waiting for your next video harry Bhai

Ответить
CodeWithWisal
CodeWithWisal - 01.10.2022 16:14

Harry bhai I have never seen a mentor like you. Love from Pakistan 🥰

Ответить
shreyansh srivastava
shreyansh srivastava - 01.10.2022 16:07

is this course over??

Ответить
Prabhjot Kaur
Prabhjot Kaur - 01.10.2022 13:17

I am in third year. Plz tell how we can apply for internship(8th sem)in front end developer i Canada, Australia, or in good companies like infosys

Ответить
Mithun Pal
Mithun Pal - 01.10.2022 11:14

harry sir bahut din ho gye video ni aayi?

Ответить
Abhay Kumar
Abhay Kumar - 01.10.2022 10:38

Harry bhai aage ki video 📷 jaldi lao 😍😍😍

Ответить
piyush aman
piyush aman - 30.09.2022 19:55

Bro complete nhi krna kya yeh series

Ответить
pahari roster
pahari roster - 30.09.2022 18:06

bhai ye tutorial bhut useful the or ab node ki videos bnao

Ответить
Lovely Sharma
Lovely Sharma - 30.09.2022 15:04

It's not good , countinue video nhi ari h . I m very disappointed . Please make videos daily in this tutorial .phle ki trh nhi rha course boring ho gya h ab , please complete this course and cover all remaining topics

Ответить
jitendra mistry
jitendra mistry - 30.09.2022 09:05

waiting for next lecture video 🙏❤

Ответить
jitendra mistry
jitendra mistry - 30.09.2022 09:05

javascript lecture is completed or more lecture sir ??

Ответить
Chetan Gupta
Chetan Gupta - 29.09.2022 22:35

Sir please continue the series...

Ответить
Aman Thakur
Aman Thakur - 29.09.2022 22:09

bhaiya jese m javaScript pr kaam kr rha hu .to kya m DSA javaScript m kr skta hu ? ya mujhe " JAVA" ya " C++" m hi krni hogi ?

Ответить
Aman Thakur
Aman Thakur - 29.09.2022 22:09

bhaiya jese m javaScript pr kaam kr rha hu .to kya m DSA javaScript m kr skta hu ? ya mujhe " JAVA" ya " C++" m hi krni hogi ?

Ответить
Aman Thakur
Aman Thakur - 29.09.2022 22:09

bhaiya jese m javaScript pr kaam kr rha hu .to kya m DSA javaScript m kr skta hu ? ya mujhe " JAVA" ya " C++" m hi krni hogi ?

Ответить
Aman Thakur
Aman Thakur - 29.09.2022 22:09

bhaiya jese m javaScript pr kaam kr rha hu .to kya m DSA javaScript m kr skta hu ? ya mujhe " JAVA" ya " C++" m hi krni hogi ?

Ответить
just like you
just like you - 29.09.2022 21:44

How many videos total in this course ?

Ответить
Singhoustic
Singhoustic - 29.09.2022 21:11

next video upload kr do bhai

Ответить
Aniket Nitnaware
Aniket Nitnaware - 29.09.2022 18:58

Ye Course Shayad VS Code Mein hota to aur maza ata.. 😔😔
Vs Code se Used to hoon ....🙃🙃

Ответить
Twinkle Upadhyay
Twinkle Upadhyay - 29.09.2022 16:29

Harry bhaiya next video kab ayega 🙁waiting ..

Ответить
Vansh
Vansh - 29.09.2022 15:40

Sir, please upload the next video of Ultimate javascript course.

Ответить
Aashish Gupta
Aashish Gupta - 29.09.2022 06:48

java me DSA start karo please....
JAVA+DSA
JAVA+DSA
JAVA+DSA
JAVA+DSA
JAVA+DSA
JAVA+DSA.
JAVA+DSA
JAVA+DSA

Ответить
Hamro Katha.
Hamro Katha. - 29.09.2022 05:11

Harry sir mere visual studio code me bohat dinen se scroll karte samay Kuch Kuch tags wale line scroll NAHI hote top me he rehte he me kya karu ?? ... Pls sir Ripley me with short video 😭

Ответить