Home of web learners

www.webn3rd.com

javascript has option to use date and time for your website

Lets start:

<html>
<head>
    
</head>
<body>
    <script>
 
var dt = new Date();
document.write(dt);
    
</script>       
</body>
</html>

output:

Here,it show all the details of date and time

Lets grab only the year

<html>
<head>
    
</head>
<body>
    <script>
 
var dt = new Date();
document.write(dt.getFullYear());
    
</script>       
</body>
</html>

output:

Here,from the getFullYear method we are getting only the full current year

Lets grab only the month

<html>
<head>
    
</head>
<body>
    <script>
 
var dt = new Date();
document.write(dt.getMonth());
    
</script>       
</body>
</html>

output:

Here,from the getMonth method we are getting only the current month in number like january is 0 as starts from 0

webn3rd.com

About webn3rd