mongoDB collection has the date field I'm trying to display on my form as:
issueDate: 2020-10-09T00:00:00.000Z
My handlebars view is only attempting to display the formatted date...like so:
</div>
<div class="form-group">
<label>Date Added</label>
<input type="date"
class="form-control"
name="issueDate"
placeholder="MM/dd/yyyy"
value="{{formatDate document.issueDate}}">
<div class="text-danger">
{{document.issueDate}}
</div>
</div>
I'm sending this mongoDBDate to my handlebars helper formatDate:
Thu Oct 08 2020 20:00:00 GMT-0400 (Eastern Daylight Time)
My formatDate handlebars.helper code is:
hbs.handlebars.registerHelper("formatDate", function(mongoDBDate) {
if (!mongoDBDate == "") {
var displayDate = format(new Date(mongoDBDate), "yyyy-MM-dd", {timeZone: "America/New_York"});
return displayDate
}
else {
return mongoDBDate;
}
})
But regardless of what date is in mongoDB or passed to the helper...the helper appears to receive the date of the day before. I see nothing that could be doing this. I suspected it's a timezone issue (mongoDB storing dates in GMT)...but I have tried a number of things to no avail.
Any suggestions welcome!