计算已经过去的一天的百分比 [英] Work out the percentage of the day that has elapsed

查看:126
本文介绍了计算已经过去的一天的百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



从本质上讲,如果时间是晚上12点,经过的百分比将是50%,上午6点将是25%而下午16点将是75%。



鉴于目前的时间,你如何计算出已经通过的一天?

解决方案

假设你可以得到当前的时间,那么计算一天的百分比就很容易了。

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


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 be 75%.

Given the current time, how could you work out the amount of day that already passed?

解决方案

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

这篇关于计算已经过去的一天的百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆