Skip to main content

Digital Clock JAVA script

const hourEl = document.getElementById("hour")
const minuteEl = document.getElementById("minutes")
const secondEl = document.getElementById("seconds")
const ampmEl = document.getElementById("ampm")

function updateClock(){
    let h = new Date().getHours()
    let m = new Date().getMinutes()
    let s = new Date().getSeconds()
    let ampm = "AMPM"

    if(h > 12){
        h = h- 12
        ampm = "PM"
    }

    h = h<10 ? "0" + h : h;
    m = m<10 ? "0" + m : m;
    s = s<10 ? "0" + s : s;

    hourEl.innerText = h;
    minuteEl.innerText = m;
    secondEl.innerText = s;
    ampmEl, (innerText = ampm);
    setTimeout(()=> {
        updateClock()
    }, 1000)
}

updateClock();







Comments

Popular posts from this blog

Favicon

       A favicon (short for "favorites icon") is a small icon that appears in the browser's address bar or next to the website's name in a list of bookmarks. They can also be displayed in the browser's tab. It is used to help users quickly identify a website or webpage. They are typically 16x16 pixels in size and are saved in the .ico file format. They can be added to a website by linking to the favicon file in the HTML code or by placing the file in the website's root directory. TELUGU      ఫావికాన్ ("ఫేవరెట్స్ ఐకాన్") అనేది బ్రౌజర్ యొక్క చిరునామా పట్టీలో లేదా బుక్ మార్క్ ల జాబితాలో వెబ్ సైట్ పేరు పక్కన కనిపించే ఒక చిన్న చిహ్నం. వాటిని బ్రౌజర్ ట్యాబ్ లో కూడా డిస్ ప్లే చేయవచ్చు. వెబ్ సైట్ లేదా వెబ్ పేజీని వేగంగా గుర్తించడంలో వినియోగదారులకు సహాయపడటానికి ఇది ఉపయోగించబడుతుంది. అవి సాధారణంగా 16x16 పిక్సల్స్ సైజులో ఉంటాయి మరియు .ico ఫైల్ ఫార్మెట్ లో సేవ్ చేయబడతాయి. హెచ్ టిఎమ్ ఎల్ కోడ్ లోని ఫావికాన్ ఫైల్ కు లింక్ చేయడం ద్వారా లేదా వెబ్ సైట్ యొక్క రూట్ డైరె...

What is coding

     Coding is the process of using a programming language to create software, scripts, or other sets of instructions for computers to execute. It involves writing code in a programming language, such as Python or Java, and using that code to create software programs, mobile apps, websites, and other types of applications. The code written by a programmer is then compiled or interpreted in order to convert it into a form that can be executed by the computer. TELUGU      కోడింగ్ అనేది కంప్యూటర్లు అమలు చేయడానికి సాఫ్ట్వేర్, స్క్రిప్ట్లు లేదా ఇతర సూచనలను సృష్టించడానికి ప్రోగ్రామింగ్ భాషను ఉపయోగించే ప్రక్రియ. ఇది పైథాన్ లేదా జావా వంటి ప్రోగ్రామింగ్ భాషలో కోడ్ రాయడం మరియు సాఫ్ట్ వేర్ ప్రోగ్రామ్ లు, మొబైల్ అనువర్తనాలు, వెబ్ సైట్ లు మరియు ఇతర రకాల అనువర్తనాలను సృష్టించడానికి ఆ కోడ్ ను ఉపయోగించడం. ప్రోగ్రామర్ రాసిన కోడ్ కంప్యూటర్ ద్వారా అమలు చేయగల రూపంగా మార్చడానికి కంపైల్ చేయబడుతుంది లేదా వ్యాఖ్యానించబడుతుంది. HINDI      कोडिंग कंप्यूटर को निष्पादित...