D
D
Darkness2019-11-11 13:45:00
JavaScript
Darkness, 2019-11-11 13:45:00

How to correctly display the time according to the template that came from the server?

The time from the server comes in the following format: "2 3:4:0.0"
Where, 2 - days, 3 - hours, 4 - minute. You can get rid of 0.
There is a place where you can select the time, after selecting the values ​​​​are substituted and displayed normally (for example, 2d. 3h. 4m.)
This thing does it:

{{ timeDays ? `${timeDays}д.` : '' }} {{ timeHours ? `${timeHours}ч.` : '' }} {{ timeMinutes ? `${timeMinutes}м.` : '' }}

When you select the time, everything works and displays normally.
Question :
How can I, when receiving the data that I indicated above, immediately show beautifully, as when choosing? Break and throw in timeDays and so on.? Split and assemble separately? Simple task, and already spent an hour, thanks for your time!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2019-11-11
@AntonBrock

Use the moment plugin

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question