JavaScript Date Objects


JavaScript Date Output

By default, JavaScript will use the browser's time zone and display a date as a full text string:

Sat Oct 12 2019 11:20:40 GMT+0530 (India Standard Time)


You will learn much more about how to display dates, later in this tutorial.

Creating Date Objects

Date objects are created with the new Date() constructor.

There are 4 ways to create a new date object:


new Date()

new Date(year, month, day, hours, minutes, seconds, milliseconds)

new Date(milliseconds)

new Date(date string)

new Date()

new Date() creates a new date object with the current date and time:


Example

var d = new Date();

Jay Kakadiya

Jay Kakadiya Creator

I am a computer field, & i am Web developer.

Suggested Creators

Jay Kakadiya