1var today = new Date();
2var dd = String(today.getDate()).padStart(2, '0');
3var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
4var yyyy = today.getFullYear();
5
6today = mm + '/' + dd + '/' + yyyy;
7document.write(today);
1date.toString('YYYY-MM-dd'); 'Tue Feb 10 2015 15:42:50'
2
3var date = new Date('4-1-2015');
4
5date.getDay();// returns 3
6
7date.getYear();// returns 115, no of years after 1900
8
9date.getFullYear();// returns 2015
10
11date.getMonth();// returns 3, starting 0 with jan
12
13date.getUTCDate();// returns 31
1var utc = new Date().toJSON().slice(0,10).replace(/-/g,'/');
2document.write(utc);