时代比较bsd/MacOSX [英] epoch time comparison bsd / MacOSX

查看:43
本文介绍了时代比较bsd/MacOSX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对除了我以外的所有人来说都是显而易见的,

This should be obvious to all but me,

我有一个充满纪元时间戳的文件,我正在尝试获取最近7天的记录.

I have a file full of epoch timestamps and I'm trying to get the records from the last 7 days.

因此我在Mac中尝试了此操作:

So I tried this in my mac:

PAST=$(gdate -d "7 days ago" +%s)
if [ $timeval -gt  $PAST ]; then
  do stuff 
 fi

示例错误输出:

TS from data, Human fr data, TS from $PAST, Human from $PAST
1419981977690,Tue Jun  9 06 14 50 PST 46967,1421129827,Mon Jan 12 22 17 07 PST 2015
1419400311440,Thu Jan  2 00 17 20 PST 46949,1421129827,Mon Jan 12 22 17 07 PST 2015
1420341489480,Fri Oct 30 06 38 00 PST 46978,1421129827,Mon Jan 12 22 17 07 PST 2015
1421232275040,Thu Jan 22 07 04 00 PST 47007,1421129827,Mon Jan 12 22 17 07 PST 2015

推荐答案

文件中的时间戳以毫秒为单位,而不是秒.将它们除以1000.

The timestamps in your file are in milliseconds, not seconds. Divide them by 1000.

这篇关于时代比较bsd/MacOSX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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