Without adequate examples I keep going around in circles to get the 'seconds' version of iso8601 printed out by 'date'. Please look at the help that is provided with date with busybox 1.22.1. I can't seem to understand the syntax required. Examples speaks louder than words in my experience and I haven't found anything that could be useful online.
Here is what I tried:
➤ date -I=seconds
➤ date -I SPEC='seconds'
➤ date -I seconds
➤ date -I='seconds'
➤ date -I 'seconds'
➤ date -I['seconds']
➤ date -I TIMESPEC='seconds'
➤ date -I TIMESPEC=seconds
Note I have tried to use the Ubuntu version of date and was able to figure out how to get the iso8601=seconds format of date, but not in busybox...
Here is what the help of date shows for Busybox 1.22.1:
BusyBox v1.22.1 (2014-09-26 07:33:17 CEST) multi-call binary.
Usage: date [OPTIONS] [+FMT] [TIME]
Display time (using +FMT), or set time
[-s,--set] TIME Set time to TIME
-u,--utc Work in UTC (don't convert to local time)
-R,--rfc-2822 Output RFC-2822 compliant date string
-I[SPEC] Output ISO-8601 compliant date string
SPEC='date' (default) for date only,
'hours', 'minutes', or 'seconds' for date and
time to the indicated precision
-r,--reference FILE Display last modification time of FILE
-d,--date TIME Display TIME, not 'now'
-D FMT Use FMT for -d TIME conversion
The documentation (i.e., the help) is confusing and doesn't lead to a pleasant experience for a simple functionality. Instead the documentation needs to be re-written such that example command line inputs are also a part of help (at least to get the syntax down). In any case, I answered my own question.
The main and very subtle difference in one of my tries that I happened to miss:
➤ date -I 'seconds'
date: invalid date 'seconds'
Was off by a hair. It needed to remove the space:
➤ date -I'seconds'
2017-07-09T17:29:54-0400
Now busybox date is happy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With