将时间与亚秒级精度进行比较 [英] Comparing times with sub-second accuracy

查看:695
本文介绍了将时间与亚秒级精度进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取自纪元以来的毫秒数?

How can I get the number of milliseconds since epoch?

请注意,我需要实际的毫秒数,而不是秒数乘以1000.我正在比较时间少于一秒且需要毫秒精度的内容的时间. (我查看了很多答案,它们似乎都带有* 1000)

Note that I want the actual milliseconds, not seconds multiplied by 1000. I am comparing times for stuff that takes less than a second and need millisecond accuracy. (I have looked at lots of answers and they all seem to have a *1000)

我正在将POST请求中的时间与服务器上的结束时间进行比较.不管是什么,我只需要两次使用相同的格式.我认为Unix时间可以工作,因为Javascript具有获取该功能的功能

I am comparing a time that I get in a POST request to the end time on the server. I just need the two times to be in the same format, whatever that is. I figured unix time would work since Javascript has a function to get that

推荐答案

time.time() * 1000 将会为您提供毫秒级的精度.

time.time() * 1000 will give you millisecond accuracy if possible.

这篇关于将时间与亚秒级精度进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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