JavaScript does not inherently have a date data type, however you can utilize the Date object with its methods to create date and time.
JS stores dates as Unix Timestamps, giving the number in miliseconds since January 1, 1970, 00:00:00.
The Date object range is -100,000,000 to 100,000,000 days, relative to January 1, 1970, UTC.
To create a Date object, type this:
var dateObjectName = new Date([parameters]);
Where dateObjectName is the name of the Date that is created, it can serve as a new object or property.
Calling Date without new returns a string representing the current date and time.
Challenge
Using the Date object, determine the date and time that is 100,000,000,000 miliseconds from January 1, 1970.
Answer Code:
var miliDate = new Date(100000000000); // Sat Mar 03 1973 04:46:40 GMT-0500 (EST)
Date Object Properties
Date.constructor() // Returns the function that created the Date object's prototype
Date.prototype() // Allows you to add properties and methods to an object
Date Object Methods
getDate() // Returns the day of the month (from 1-31)
getDay() // Returns the day of the week (from 0-6)
getFullYear() // Returns the year
getHours() // Returns the hour (from 0-23)
getMilliseconds() // Returns the milliseconds (from 0-999)
getMinutes() // Returns the minutes (from 0-59)
getMonth() // Returns the month (from 0-11)
getSeconds() // Returns the seconds (from 0-59)
getTime() // Returns the number of millseconds since midnight Jan 1, 1970, and a specific date
getTimezoneOffset() // Returns the time difference between UTC time and local time, in minutes
getUTCDate() // Returns the day of the month, accoridng to the universal time (from 1-31)
getUTCDay() // Returns the day of the week, according to the universal time (from 0-6)
getUTCFullYear() // Returns the year, according to the universal time
getUTCHours() // Returns the hour, according to the universal time (from 0-23)
getUTCMilliseconds() // Returns the milliseconds, according to the universal time (from 0-999)
getUTCMinutes() // Returns the minutes, according to the universal time (from 0-59)
getUTCMonth() // Returns the month, according to the universal time (from 0-11)
getUTCSeconds() // Returns the second, according to the universal time (from 0-59)
now() // Returns the number of milliseconds since midnight Jan 1, 1970
parse() // Parses a date string and returns the number of milliseconds since Jan 1, 1970
setDate() // Sets the day of the month of a date object
setFullYear() // Sets a year of a date object
setHours() // Sets the hour of a date object
setMilliseconds() // Sets the milliseconds of a date object
setMinutes() // Sets the minutes of a date object
setMonth() // Sets the month of a date object
setSeconds() // Sets the seconds of a date object
setTime() // Sets a date to a specified number of milliseconds after/before Jan 1, 1970
setUTCDate() // Sets the day of the month of a date object, according to universal time
setUTCFullYear() // Sets the year of a date object, according to universal time
setUTCHours() // Sets the hours of a date object, according to universal time
setUTCMilliseconds() // Sets the milliseconds of a date object, according to universal time
setUTCMinutes() // Sets the minutes of a date object, according to universal time
setUTCMonth() // Sets the month of a date object, according to universal time
setUTCSeconds() // Sets the seconds of a date object, according to universal time
toDateString() // Converts the date portion of the Date object into a readable string
toISOString() // Returns the date as a string, using the ISO standard
toJSON() // Returns the date as a string, using the JSON format
toLocaleDateString() // Returns the date portion of a Date object as a string, using locale conventions
toLocaleTimeString() // Returns the time portion of a Date object as a string, using locale conventions
toLocaleString() // Converst a Date object to a string, using locale conventions
toString() // Converts a Date object to a string
toTimeString() // Converts the time portion of a Date object to a string
toUTCString() // Converts a Date object to a string, according to universal time
UTC() // Returns the number of milliseconds in a date since midnight of Jan 1, 1970, according to universal time
valueOf() // Returns the primitive value of a Date object