Receiving the date time
value from the server and storing it in a variable named a1
:
let a1 = (new Date(estimatedServerTimeMs));
console.log of a1
Sun Apr 05 2020 11:36:56 GMT+0530 (India Standard Time)
The date is converted to a simpler format such as 5-3-2020
, but the desired format is 05-APR-2020
Here is the code snippet:
let a1 = (new Date(estimatedServerTimeMs));
console.log(a1);
let show_year_month_date = a1.getDate()+'-'+ a1.getMonth() +'-'+ a1.getFullYear();
console.log(show_year_month_date);
Desired Changes:
- Make sure the day portion displays with 2 digits.
- Convert the numeric month to a 3-character representation.