agon024 agon024 - 1 month ago 5x
AngularJS Question

AngularJS - Can't remove numbers after decimal point

Im pulling in a JSON value from and API call that is returning this date and time value:

2016-07-25 10:50:14.000

Im trying to remove the last 3 zeros but don't know how to do this.

I have tried:

<div class="createdOn">Created On: {{ details['Created At'] | number:2 }} </div>

But that displays nothing at all. Is there a way for me to use jQuery to grab that text and then remove the zeros at the end?

Thanks for any help.


Your date is in fact a string. So in angular that should work :

 <div class="createdOn">Created On: {{ details['Created At'] | limitTo:19 }}</div>

For ref :

Like str point it, you can too treat it like a date (your format permit it and it's perhaps a better solution):

{{ details['Created At'] | date:'yyyy-MM-dd HH:mm:ss' }}