How to fetch current date and time using Javascript

JavaScript Current Time Clock

With the newly created Date Object we can show the current date and time, now only a variable which store the current date and time. We have to only print the information.

To print the information we have to utilize all the given blow function.

getTime() – Number of milliseconds since 1/1/1970 @ 12:00 AM

getSeconds() – Number of seconds (0-59)

getMinutes() – Number of minutes (0-59)

getHours() – Number of hours (0-23)

getDay() – Day of the week(0-6). 0 = Sunday, … , 6 = Saturday

getDate() – Day of the month (0-31)

getMonth() – Number of month (0-11)

getFullYear() – The four digit year (1970-9999)

Now we can print the date and time information according to to their format.


<script type=”text/javascript”>


var currentTime = new Date()

var month = currentTime.getMonth() + 1

var day = currentTime.getDate()

var year = currentTime.getFullYear()

document.write(month + “/” + day + “/” + year)



To seek challenging roles and to achieve excellence in the field of Open Source Web Technology with a profound spirit of commitment and dedication.

Share This Post

Related Articles

© 2017 Sumit Bansal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Powered by WordPress · Designed by Theme Junkie