urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

amDateFormat showing formatted dates of day before when using with moment-timezone #293

Open Jaspur opened 6 years ago

Jaspur commented 6 years ago

Code:

<div class="the-date" ng-title="energy.date">
    <h5>{{ energy.date | amDateFormat:'dddd' }}</h5>
    <h4>{{ energy.date | amDateFormat:'D MMMM YYYY' }}</h4>
</div>

Result: schermafdruk 2017-07-18 21 55 32

It's 1990-04-30, but it shows via amDateFormat 29 april 1990. So an incorrect date. Same for the day; it shows "zondag" (Sunday), but it should be Monday.

Timezone is configured correctly:

app.constant('angularMomentConfig', {
    timezone: 'Europe/Amsterdam'
});

When I run it via the default moment()-function like this:

console.info(energy.date);
console.info(moment(energy.date));

It's showing it correctly: schermafdruk 2017-07-18 22 02 52

It happens by multiple dates in the past, so is it a bug in the amDateFormat somewhere? When I remove moment-timezone as a dependency it shows it all correctly.. Why is this?