1

I know the command is date +%s -d "xxx"

But how do I convert 11/03/2018 02:44:58 to epoch ?

root@AngelBeats:~# date +%s -d "11/03/2018 02:44:58"
date: invalid date '11/03/2018 02:44:58'
jww
  • 90,984
  • 81
  • 374
  • 818
Joe
  • 561
  • 1
  • 7
  • 20

2 Answers2

2

Edit: For Linux

date --date="11/03/2018 8:15:00" +"%s"

1520736300


This should do it.(For OSX Systems)

date -j -f "%d/%m/%Y %H:%M:%S" "11/03/2018 8:15:00" +"%s"

1520736300

The "-f" specifier can be used to set the format.

Yuvraj Jaiswal
  • 1,504
  • 10
  • 18
1

-j is for BSD systems. On Linux, use this:

date -d "11/03/2018 8:15:00" +"%s"
codeforester
  • 34,080
  • 14
  • 96
  • 122