Transforming a date and time
Transforming a date
A date is stored in the database as 2020-01-23 (YYYY-MM-DD).
//For example: Today's date is 28th September 2017 var myDate = new Date(); //The value of myDate = 2017-09-28T15:26:19.259Z //I want to extract only the date using the toISODateString() method var dateOnly = myDate.toISODateString(); //Now the value of dateOnly = 2017-09-28
A time is stored in the database as 15:26:19.259 (HH-MM-SS.SSS).
//For example: I want to get the current time in HH:MM var myDate = new Date(); //The value of myDate = 2017-09-28T15:26:19.259Z //I want to extract only the date using the toISOTimeString() method var dateOnly = myDate.toISOTimeString(); //Now the value of dateOnly = 15:26