felixge/node-dateformat

Invalid dates generating for "MM-dd-yyyy'T'HH:mm:ssZ"

aniltallam opened this issue · 2 comments

var dateFormat = require("dateformat");
var date = new Date(1630004827000) // 2021-08-26T19:07:07.000Z

console.log(dateFormat(date, "MM-dd-yyyy'T'HH:mm:ssZ")) // prints '37-27-2021T00:08:07GMT+0530'

node-dateformat npm module version: 4.5.1

hi
try
console.log(dateFormat(date, "UTC:mm-dd-yyyy'T'HH:MM:ssZ"))

lowercase m is for months where is uppercase M is for minutes. appending utc to the mask value converts time to the desired timezone.

Closing as the issue should now be resolved.