Skip to content

Get Todays Date In Javascript

October 31, 2014

Here’s a very quick tip to get todays date in Javascript, heres the code to do so: –

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

if (dd < 10) {
dd = ‘0’ + dd;
}

if (mm < 10) {
mm = ‘0’ + mm;
}

today = mm + ‘/’ + dd + ‘/’ + yyyy;

—————————-

So it should show 10/31/2014

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: