Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How do I substract 5 minutes from a Unix timestamp?

I have a date in milliseconds since Unix epoch format, how do I substract 5 minutes from it?
by

1 Answer

Bharatgxwzm
5 minutes of 60 seconds of 1000 milliseconds each gives 300000.

You can subtract this from a variable that containts current date in milliseconds using $(( )):
dd=$(($(date +'%s * 1000 + %-N / 1000000')))
ddmin5=$(($dd - 300000))
echo $ddmin5

Login / Signup to Answer the Question.