0

I'm getting date from a rest service as

$scope.dob="1989-10-17 00:00:00"

How can I convert /apply filter to this date to look like normal date (without time).

I tried with splicing the time part but this is inside ng-repeat.It's not working

3
  • Have you tried {{ dob | date:'short' }} in the template? See docs.angularjs.org/api/ng/filter/date Commented Jan 14, 2015 at 11:36
  • Yes @Dimitry.Not working Commented Jan 14, 2015 at 11:39
  • {{ dob | date:'shortDate' }} this should just get the date Commented Jan 14, 2015 at 11:40

1 Answer 1

3

Please note the format date filter understands:

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.

"1989-10-17 00:00:00" can't be parsed. Instead it should be: "1989-10-17T00:00:00Z"

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

1 Comment

You're welcome. Also consider using timestamps instead of string.

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.