【问题标题】:How would to compare two timestamp如何比较两个时间戳
【发布时间】:2021-04-25 18:20:15
【问题描述】:

在我的应用程序中,我有两个 UTC 时间戳,需要比较它们。我如何才能获得更大的时间戳?

var ts1=1611169043381; //UTC timestamp in string format
var ts2=1611184342102; //UTC timestamp in string format

比较后想知道哪个时间戳大于另一个

在 JSON 中,st1 是字符串格式

"st1": {
    "value": "1611169043381",           
    "source": "CRM_UI",
    "sourceId": "info@pearagon.com",
    "updatedByUserId": 8966293,
    
}

【问题讨论】:

标签: javascript node.js time timestamp


【解决方案1】:

由于这些时间戳表示自纪元以来的毫秒数,您可以使用ts1 > ts2 来找出ts1 是否更大。如果您的值在 st1 之类的对象中,则只需执行 st1.value > st2.value

【讨论】:

    猜你喜欢
    • 2012-02-04
    • 2016-08-06
    • 2015-01-02
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多