Save date variables epoch format



Hi all.
I need to create a script that pulls data from a X source with the following format:

pingdom-run-export --config config_spec.yml --type results --checks-from $from --checks-to $to

I need to set from and to variables on the script and both variables needs to be at epoch format.
This is how I started my script:

from=$(date +"%s" - 604800)
to=$(date +%s)

Any ideas?


What is the purpose of this?

from=$(date +"%s" - 604800)

Do you want to get epoch for past date? Like 7 days back? If so try:

date -d "Feb 21 2018" +%s
date --date "7 days ago" +"%s"


It gives the Epoch time format i.e. Unix timestamp format which is defined:
Sum of seconds since standard epoch of 1/1/1970