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
  • 97,681
  • 90
  • 411
  • 885
Joe
  • 791
  • 1
  • 9
  • 24

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,605
  • 13
  • 20
1

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

date -d "11/03/2018 8:15:00" +"%s"
codeforester
  • 39,467
  • 16
  • 112
  • 140