Moustafa Moustafa -4 years ago 142
Linux Question

Date time to Epoch conversion

I have a variable defined with date time format and want to convert it to epoch format in bash script

Input
Var=20170520;

Output:
Epoch format

Answer Source

Try

date=20170520 # i.e. 2017 05 20
date -d "$date" +%s
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download