How do I do date math in a bash script on OS X Leopard?

后端 未结 8 913
迷失自我
迷失自我 2021-02-03 21:15

I realize I could whip up a little C or Ruby program to do this, but I want my script to have as few dependencies as possible.

Given that caveat, how does one d

相关标签:
8条回答
  • 2021-02-03 21:36

    I used the following on, macOS Mojave 10.14.5, to find the DHCP renewal time open

    date -v +`ipconfig getoption en0 renewal_t1_time_value`S
    
    0 讨论(0)
  • 2021-02-03 21:45

    You might be looking for this. gdate '+%s' -d '2 weeks ago' or gdate '+%s' -d '1 day ago'

    These two examples return in the Epoch time. I turn those seconds in to something my language can read normal strptime(seconds, '%s'). Python Ruby and Javascript are the few I know have it. I am sure Java and all the others do as well.

    Also gdate is date (GNU coreutils) it just called something different on mac. Strange thing is on my other mac it let me use just data to get this same off set. Don't know why might be they change something recently.

    0 讨论(0)
提交回复
热议问题