Merge pull request #2076 from AasthaSinha2305/master

Explained how to create a date object.
This commit is contained in:
Ilya Kantor 2020-08-24 09:24:35 +03:00 committed by GitHub
commit b0c5dad519
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,17 @@ The `new Date` constructor uses the local time zone. So the only important thing
So February has number 1.
Here's an example with numbers as date components:
```js run
let d = new Date(2012, 1, 20, 3, 12);
alert( d );
//new Date(year, month, date, hour, minute, second, millisecond)
let d1 = new Date(2012, 1, 20, 3, 12);
alert( d1 );
```
We could also create a date from a string, like this:
```js run
//new Date(datastring)
let d2 = new Date("February 20, 2012 03:12:00");
alert( d2 );
```