Javascript Date

tutorial and example
tutorial and example

JavaScript Date

In JavaScript Date Object is data type build into the JavaScript language. Data object are created with the new Date(). JavaScript Date instance that represents a single moment in time. JavaScript date object can only be instantiated by calling JavaScript as a constructor.

Syntax

We can use following syntaxes to create a Date object using Date() constructor.

NOTE: Parameters in bracket is always optional.

Here descriptions of parameter:

value

It representing the number of milliseconds since 1 January 2017 00:00:00 UTC, with leap seconds ignored.

dataString

String value representing a date. The string should be in a format recognized by the Date.parse()method.

year

Integer value representing the year. Value from 0 to 99 map of the years 2000 to 2099.

month

Integer value representing the month, beginning with 0 for January to 11 for December.

date

Optional. Integer value representing the day of the month.

hours

Optional. Integer value representing the hours of the day.

minutes

Optional. Integer value representing the minute segment of a time.

seconds

Optional. Integer value representing the second segment of a time.

milliseconds

Optional. Integer value representing the millisecond segment of a time.

Exmple of Date

Try Now

Output

Example of current time

Try Now

Output