Work out the percentage of the day that has elapsed

前端 未结 5 579
深忆病人
深忆病人 2021-01-12 10:10

Slightly strange question, but hopefully someone can help.

In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would

5条回答
  •  孤街浪徒
    2021-01-12 10:43

    Assuming you can get the current time of day, it'd be pretty easy to calculate the percentage of the day elapsed.

    percentage = (hours / 24 + minutes / (60 * 24)) * 100
    

提交回复
热议问题