I need to tell you how much time I have for a certain timer, I have the date from which I started the event.
I'm developing with angular 4
typescript
and I use plugin moment js
In my html I'm doing this:
<div class="row card-indicator centralize-text">
{{((locations[indiceMotorist]?.trip.createdAt == undefined)? '0' : locations[indiceMotorist]?.trip.createdAt) | amDifference: today :'minutes' : true }}
</div>
The content that is printed on the screen is:
-62.444583333333334
My date is in this format, and it comes from my server:
createdAt: "2017-11-01T13:13:59.015Z"
One important point is that I can not use the date on my computer because the server's time and the client's pc can be out-of-date. To solve this problem from time to time I send a location that also contains a time from the server.
createdAt: "2017-11-01T14:22:23.466Z"
I'm thinking of making the end date (in the case I told you of the location) - the start date, in order to get the time that is in progress.
I do not know if I can do this with moment js, but I need to do this, how can I get it?
There is a plugin that makes it easy, or even% native, to solve my problem.