0

I am trying to display timestamp using angular. At the backend on console log I am getting date like this 2020-09-03 00:00:00.0 but when I trying to get date at frontend it is displaying like this 1600021800000. How can I display date in regular format?

This how I get date on console using spring boot -

enter image description here

And when get it at frontend it display like this -

enter image description here

How can I display date like this 2020-09-03 00:00:00.0?

3
  • is your dateTime on UI is a type of Long ? new can display as new Date(dateTime) anyway Commented Sep 28, 2020 at 10:17
  • this date is automatically created at the time of registration of user at the backend i used private Timestamp dateTime; Commented Sep 28, 2020 at 10:20
  • @Dmitri Algazin i think i am getting time in seconds at frontend. Commented Sep 28, 2020 at 13:29

1 Answer 1

1

Suppose your date is in $scope.dateTime

<p>{{dateTime | date:'yyyy-MM-dd HH:mm:ss.sss'}}</p>

Just put this wherever you want to show your formatted date in your HTML. Look up angularjs date api for more information regarding formatting

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

1 Comment

yeah 1600021800000 this is date in miliseconds. so i need to convert in date.

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.