I have date format like 2016-02-26 14:12:36., I have to convert it into unix epoch time. I have the option to convert current time to epoch time using command : date +%s, however how to convert a specific date to epoch unix time
Asked
Active
Viewed 2,449 times
2 Answers
0
On the command line you convert the date provided to the UNIX epoch time like this:
date -j -f "%Y-%m-%d %H:%M:%S" "2016-02-26 14:12:36" "+%s"
This is on os x. The manual for date have some examples and strftime have all the formatting needed.

kometen
- 6,536
- 6
- 41
- 51
0
You can get seconds since the epoch from date like this ,
$ SECFROMEPOCH=`date --date="2016-02-26 14:12:36" +%s`
And then you can check the value that date gave back to you like this,
$ echo $SECFROMEPOCH | awk '{print strftime("%c",$1)}'

Flannon
- 101
- 1
- 5