Dates & Times
Date objects use an integer value that is the number of milliseconds since 1 January 1970 UTC.
Dates are based on a time value that is the number of milliseconds since 1 January 1970 UTC.
The default date format is MM/DD/YYYY
myDate.toISOString() converts a date to a string with format YYYY-MM-DD T HH:mm:ss.sss2 ?
The Date is infact an interface not a data type
var date1 = new Date("January 5, 2019 02:36:00")
console.log(date1)
JavaScript counts months from 0 to 11.
Dates are declared using the Date constructor
This is an object
The month parameter is zero based
var myDate = new Date(2020,11,01); //this is December
var myDate = new Date("1 July 2020");
var myTodaysDate = new Date();
const myDate = '20.10.1999';
var myDate = new Date();
var myHour = myDate.getHours();
By default, JavaScript will use the browser's time zone and display a date as a full text string:
Tue Jul 06 2021 15:14:53 GMT+0100 (British Summer Time)
Printing Dates
By default console.log will output using a standardised output that is not 1-based.
All times are based on UTC
var myDate = new Date(2020, 7, 14);
console.log(myDate); // 2020-08-14 ??????
Datejs library
datejs.com
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopNext