agon024 agon024 -4 years ago 115
Javascript Question

AngularJS - Can't remove numbers after decimal pont

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.

Answer Source

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 to treat it like a date (your format permit it):

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download