date function in javascript

technical talkiess
0

 Javascript Date and Time :- 


<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Javascript date </title>

</head>

<style>

    .container{

        background-color: rgb(173, 101, 6);

        padding: 23px;

        color: white;

        border: 1px solid black;

        text-align: center;

    }

    #time{

        font-weight: bold;

        color: black;

    }

</style>

<body>

    <div class="container">

        Current Time and date :- <span id="time"></span>

    </div>

</body>

<script>

    // ye ist me date return karta hai aaj kki

    let dt = new Date();

    console.log(dt);


    // isme aap new date dal sakte hai

    // date(year,month , date ,hourse , minute ,second , milisecond)

    let newDate = new Date(2039,10,11,12,9,18)

    console.log(newDate);


    // isme se khali year chaiye to aap

    console.log(newDate.getFullYear())

    // agar apko month chaiye to aap niche wali line dal sakte hai

    console.log(newDate.getMonth())


    // if you want the date of the particular date

    console.log(newDate.getDate())


    // if you want the date of the particular date

    console.log(newDate.getDate())


    // if you want to hourse in the particular date so you can use the.... minute ... seconds  

    console.log(newDate.getHours())

    console.log(newDate.getMinutes())

    console.log(newDate.getSeconds())

    // its return utc date

    console.log(dt.getUTCDate())


    // ye date set karta hai

    newDate.setDate(12)

    console.log("new date "+newDate)

    // 1 jan 1970 se ap tak kitne mili second hue wo return karta hai

    console.log(Date.now());



    setInterval(updateTime, 1000);


    function updateTime(){

        time.innerHTML = new Date();

    }

</script>

</html>


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)