Calculate time between time-1 to time-2?

前端 未结 4 594
夕颜
夕颜 2021-02-08 13:28
enter time-1 // eg 01:12
enter time-2 // eg 18:59

calculate: time-1 to time-2 / 12 
// i.e time between 01:12 to 18:59 divided by 12

How can it be don

4条回答
  •  既然无缘
    2021-02-08 14:09

    Assuming that the user is entering strings like "01:12", you need to convert (as well as validate) those strings into the number of minutes since 00:00 (e.g., "01:12" is 1*60+12, or 72 minutes), then subtract one from the other. You can then convert the difference in minutes back into a string of the form hh:mm.

提交回复
热议问题