Date Methods tutorial in JavaScript

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Date Methods JavaScript</title>
    <script>
        var now = new Date();
        document.write(now + "<br>");
        document.write(now.toDateString() + "<br>");
        document.write(now.getDate() + "<br>");
        document.write(now.getFullYear() + "<br>");
        document.write(now.getMonth() + "<br>");
        document.write(now.getDay() + "<br>");
        document.write(now.getHours() + "<br>");
        document.write(now.getMinutes() + "<br>");
        document.write(now.getSeconds() + "<br>");
        document.write(now.getMilliseconds() + "<br>");
        // now.setDate(20);
        // document.write(now + "<br>");
        // now.setFullYear(2025);
        // document.write(now + "<br>");
        // now.setMonth(2);
        // document.write(now + "<br>");
        // now.setHours(14);
        // document.write(now + "<br>");
        document.write(now.getDate() + "/" + now.getMonth() + "/" + now.getFullYear());

        document.write("<br><br><br>");
        var nowTwo = new Date("January 5 2024");
        document.write(nowTwo.getDay() + "<br>");
        document.write(nowTwo.getMonth() + "<br>");
        document.write(nowTwo.getFullYear() + "<br>");
        //If we get any past Hour OR Minute then result will be zero
        document.write(nowTwo.getHours() + "<br>");
        document.write(nowTwo.getMinutes() + "<br><br>");
    </script>
</head>

<body>
</body>

</html>



Comments

Popular posts from this blog

Generators tutorial in Advance JavaScript

Document Object Module DOM querySelector and querySelectorAll tutorial in JavaScript

Find Even and Odd Numbers with Loops tutorial in JavaScript