create date js code example
Example 1: new date javascript
let today = new Date();
let birthday = new Date("December 17, 1995 03:24:00");
let birthday = new Date("1995-12-17T03:24:00");
let birthday = new Date(1995, 11, 17);
let birthday = new Date(1995, 11, 17, 3, 24, 0);
let birthday = new Date(628021800000);
let [month, date, year] = new Date().toLocaleDateString("en-US").split("/");
let [hour, minute, second] = new Date()
.toLocaleTimeString("en-US")
.split(/:| /);
let date = new Date(98, 1);
date.setYear(98);
date.setFullYear(98);
Example 2: javascript current date time
var today = new Date().toLocaleDateString(undefined, {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
Example 3: new date() javascript
var date = new Date();
var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);
Example 4: new date javascript
let local_date = new Date();
alert("it is " + local_date + "!")
Example 5: new Date
var mydate = new Date('23/4/2021 6:15 pm');
console.log(mydate.toDateString());