2

I'm trying to use Angular's date/time formatting with this string

2015-01-20 16:49:07+00:00

{{ myDate | date : 'medium' }}

However, it doesn't seem to be working? Is the original string messed up?

1
  • I just tried it with your string and it worked perfectly... If you take out the | date ... part and just leave it as {{ myDate }} what comes out? Commented Feb 11, 2015 at 19:19

2 Answers 2

2

According to the angular date filter docs:

Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone.

You'll notice that for an ISO 8601 date, you need a T before the time:

"2015-01-20T16:49:07+00:00"

http://jsfiddle.net/p84zjy6t/

Sign up to request clarification or add additional context in comments.

Comments

0

The correct usage is:

{{ date_expression | date : format }}

To check all format options check the docs

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.