LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Adding seconds to `date +%s` ? (https://www.linuxquestions.org/questions/linux-general-1/adding-seconds-to-%60date-s%60-446101/)

pshankland 05-18-2006 11:39 AM

Adding seconds to `date +%s` ?
 
Am sure this is a simple one but...

I am getting the date and time value back by using `date +%s` but I need to add 7200 seconds to this (2 hours), how can I do this?

Code:

start_time=`date +%s`
duration=7200
end_time=$start_time <something here> $duration

Thanks.

alunduil 05-18-2006 11:56 AM

Code:

start_time=$(date +%s)
let " finish_time = 7200 + start_time "
echo ${finish_time}

That is how I would do it.

Regards,

Alunduil


All times are GMT -5. The time now is 08:05 PM.