Hello! It's a great pleasure to have you visit my blog.
It's truly a fateful encounter. If you are interested in Chinese goods, we can collaborate.
I can provide you with affordable Chinese products that you can sell in your country, thereby boosting our economic income.


If you are willing to cooperate, I hope to hear from you to discuss the opportunity for collaboration.
Here is my Email: t@29ym.com
Looking forward to connecting with you and embarking on this partnership together!

Js和Php计算两个时间差百分比

在做项目时用到了进度条,
进度根据开始时间和结束时间的任务完成情况求得的百分比进行展现。
比如:用户设置时间2019-04-05 12:00:0到时间2019-04-05 18:10:00,
求得时间2019-04-05 12:00:0到此刻的时间距离时间2019-04-05 18:10:00走了百分之多少。
公式:此刻时间的减去开始的,除以结束的减去开始的时间
js展示:

(new Date().getTime() - new Date('2019-04-05 12:00:00').getTime()) 
/ 
(new Date('2019-04-05 18:10:00').getTime() - new Date('2019-04-05 12:00:00').getTime()) * 100

Php展示:

$time= (time()- $v['start_time']) /  ($v['end_time']- $v['start_time']) *100;
发表新评论