1var dateObj = new Date();
2var month = dateObj.getUTCMonth() + 1; //months from 1-12
3var day = dateObj.getUTCDate();
4var year = dateObj.getUTCFullYear();
5
6newdate = year + "/" + month + "/" + day;
7
1let date = new Date(); //actual time in miliseconds
2let string = date.toString();
3// expected output: Wed Jul 28 1993 14:39:07 GMT+0200 (CEST)
4// if you need more power: date-fns.js or moment.js
1const d = new Date();
2
3d.getMonth() + 1; // Month [mm] (1 - 12)
4d.getDate(); // Day [dd] (1 - 31)
5d.getFullYear(); // Year [yyyy]
1//Month -> 0= Jan, 11=Dec | myDate = 6 Dec 2019 10:45
2var myDate = new Date(2019, 11, 06, 10, 45);
3var dayInYear = Math.floor((myDate - new Date(myDate.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24));
1//create an object first to indicate what values you want to output
2var today = new Date();
3var options = {
4 weekday: "long", //to display the full name of the day, you can use short to indicate an abbreviation of the day
5 day: "numeric",
6 month: "long", //to display the full name of the month
7 year: "numeric"
8}
9//indicate the language you want it in first then use the options object for your values
10var sDay = today.toLocaleDateString("en-US", options);