0

I got a command which works perfectly on linux

date -d @$(git log -1 --format=%at) '+%Y-%m-%d_%H-%M-%S'

and now i'm trying to do same formatting with busybox, but i always fail

3
  • What version of busybox are you using? how exactly does it fail? – steeldriver Jun 11 '20 at 12:50
  • @steeldriver BusyBox v1.31.1, invalid date '1591877098' – daveN Jun 11 '20 at 13:00
  • 1
    Are you sure you didn't omit the leading @? – steeldriver Jun 11 '20 at 13:30
0

date help from the busybox docs:

date [OPTIONS] [+FMT] [TIME]

Display time (using +FMT), or set time

Options:

        [-s] TIME       Set time to TIME
        -u              Work in UTC (don't convert to local time)
        -R              Output RFC-822 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 FILE         Display last modification time of FILE
        -d TIME         Display TIME, not 'now'
        -D FMT          Use FMT for -d TIME conversion
Recognized TIME formats:

        hh:mm[:ss]
        [YYYY.]MM.DD-hh:mm[:ss]
        YYYY-MM-DD hh:mm[:ss]
        [[[[[YY]YY]MM]DD]hh]mm[.ss]

So, epoch seconds are not a valid input time format.

Does %ai or %aI not give you close enough to what you need?:

$ git help log
...
               %at
                   author date, UNIX timestamp

               %ai
                   author date, ISO 8601-like format

               %aI
                   author date, strict ISO 8601 format

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.