0

I have a date format in the following way,

"tranDate": "2015-11-02T18:30:00.000Z"

how do i format the date and time in human readable way.

date: 2015-11-02
time: 18:30:00

3 Answers 3

1

the date filter will handle the UTC datetime string as it is.

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

Comments

1

Since your string contains Zulu time, first convert the string to a date using new Date as follows:

$scope.date = new Date(obj['tranDate'].replace(' ', 'T'))

Then use angular's inbuilt date filters. in the template. Example:

{{date | date: 'd MMM yyyy'}}

Comments

0

IN CONCROLLER

put the following code in controller

$scope.date_test = {"tranDate": new Date()}

IN HTML

date : {{date_test.tranDate  | date: 'yyyy-M-dd'}}
time : {{date_test.tranDate  | date:"h:mm:ss"}} 

This is an exmaple of formating the date and time

http://plnkr.co/edit/nYChVvYOmok4jX16CNae?p=preview

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.