How to find current date in javascript

{0 Comments}

To find Current date using JavaScript you need to use Date inbuilt function. But the thing which you will notice is that, date you are getting by using inbuilt Date function is not in the correct format so you need to customize the JavaScript according to yourself. Which will give you date in proper format. The customized code for the same is below, it little bit complex but the result which you will get is more understandable and more far clear to use.

 Javascript |  copy code |? 
1
var today = new Date();
2
var dd = today.getDate();
3
var mm = today.getMonth()+1; //January is 0!
4
 
5
var yyyy = today.getFullYear();
6
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy;
7
document.write(today);
8

Leave a Comment

Your email address will not be published.