How to Format a Date in JavaScript
Formatting dates in JavaScript is a common task. There are several methods available to generate a string representation of a date object. Let’s explore the different options: Given a Date object: const date = new Date('July 22, 2018 07:22:13'); The built-in methods provide various string representations: date.toString(); // "Sun Jul 22 2018 07:22:13 GMT+0200 (Central European Summer Time)" date.toTimeString(); // "07:22:13 GMT+0200 (Central European Summer Time)" date.toUTCString(); // "Sun, 22 Jul 2018 05:22:13 GMT" date....