Save date variables epoch format

gnu
linux
bash

#1

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:

#!/bin/bash
from=$(date +"%s" - 604800)
to=$(date +%s)

Any ideas?


#2

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"

#3

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