Work out the percentage of the day that has elapsed

前端 未结 5 681
深忆病人
深忆病人 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:45

    The accepted answer bugs me for many reasons including the relationship to a real life calendar. Personally, I would probably do this:

    result:

    72.22% of the day has passed (62402 out of 86400 seconds)
    

    You could then extend it even further by making a function and changing the range from "today" and "tomorrow" to something else.

提交回复
热议问题