Javascript Data and Time scripts

Hello People of the internet,

Today I have some scripts for you I found on the internet. I was looking for some date and time scripts to help in a project I was working on. Something to display the time and date in the front end of the website. Down here is de code I found.

How to get the current date:

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {

if(mm<10) {

today = mm+'/'+dd+'/'+yyyy;

And now for the time script

var d = new Date(); // for now
var hours = d.getHours(); // => 9
var minutes = d.getMinutes(); // => 30
var seconds = d.getSeconds(); // => 51

var time = hours+':'+minutes+':'+seconds;

This piece of code is pretty small but this will display the time. As you can see it doesn’t update. You could make a function inside a Setinterval function in javascript so that it would update every second and write the new time on the document. I’m not gonna help you with that just so you can explore some more javascript off your own ;).

I would like to give credit to Samuel Meddows for posting his findings on the date.

And to  Royi Namir about his post about time.

Here are the links to the articles I used: