0

I have the following datetime:

2015-03-04T00:00:39+00:00

I am trying to display the date as follows using AngularJS

{{entry.entryDate | date:'MM/dd'}}

However, when I do this, it displays 03/03 instead of 03/04.

The date displays correctly for any time before 1900. But when a datetime is 1900 or later, it always displays 03/03 instead of 03/04.

Any idea how I can fix this?

2 Answers 2

2

According to AngularJS documentation you can find here , you can set timezone as shown below.

{{ date_expression | date : format : timezone}}
Sign up to request clarification or add additional context in comments.

5 Comments

I want to simply display 03/04. However, it is displaying 03/03 instead.
could you share a jsfiddle with your question? My best guess was that there was something wrong with the timezones.
Yes, there was something wrong with my timezone, so I created a custom filter. Thanks.
please mark as answer if you are pleased with the answer. Best.
It's indeed probably a timezone issue. There is a GMT timezone in your string, and you're displaying it in your browser's timezone. Try {{ '2015-03-04T00:00:39' | date:'MM/dd' }}.
0

I ended up creating a custom filter to format in utcTime. This SO question helped point me in the right direction.

Why is Angular date filter displaying wrong date?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.