How do you measure whole-second job duration across midnight?

Subtracting two integer unixepoch values produces an elapsed whole-second difference on the UTC timeline.

SQLite example and interpretation

A job from 23:59:58 to 00:00:03 the next day lasts five seconds. Time-of-day strings omit the date needed for that calculation.

SELECT unixepoch('2024-04-02 00:00:03')-unixepoch('2024-04-01 23:59:58');

Result [[5]]

中文

跨午夜的作业怎样精确统计整秒耗时?

对两个时刻分别求 unixepoch 再相减,得到统一 UTC 时间轴上的整秒差。

SQLite 示例与适用条件

23:59:58 启动,翌日 00:00:03 完成,耗时五秒。仅用时分秒字符串相减会丢失日期。

SELECT unixepoch('2024-04-02 00:00:03')-unixepoch('2024-04-01 23:59:58');

结果 [[5]]

References / 参考来源

Keep reading / 继续阅读