Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given -D %s busybox v1.30.1 complains about invalid date

I've been looking for a solution online but couldn't find anything useful.

Running the same command works on busybox 1.29.2 but no longer on 1.30.1.

We are trying to offset the date by running this command:

echo $(date -D %s +%m%d%H%M  -d "$(($(date +%s) - 4200))")

on 1.29.2 it gives the correct output
on 1.30.1 it gives the error message date: invalid date '1592225794'

Did something change syntax-wise? Any other ideas how to offset the date by for example +2 hours? Ideal output format is %m%d%H%M.

like image 527
thblx Avatar asked Dec 07 '25 05:12

thblx


1 Answers

I don't know what they changed, but -D %s is redundant there; busybox date supports -d @SECONDS_SINCE_EPOCH since version 1.17.x.

$ date +%m%d%H%M -d @$(($(date +%s)-4200))
06151525
$ date
Mon Jun 15 16:35:22 +03 2020
like image 169
oguz ismail Avatar answered Dec 08 '25 19:12

oguz ismail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!