[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: difference in seconds between two formatted dates ...



* 2023-12-17 10:58:28+0000, Andy Smith wrote:

> On Sun, Dec 17, 2023 at 10:12:11AM +0000, Albretch Mueller wrote:
>> you get seconds in dt00 and dt02 and then the difference. You can't
>> go: $(( dt02 - dt00 )) because bash Arithmetic is 10-based.
>
> Why don't you just get the time as epoch time e.g. "date +%s" and
> then you can subtract one from the other¹.

Also, Bash has variable EPOCHSECONDS which expands to the current Unix
epoch time.

    $ echo $EPOCHSECONDS; sleep 5; echo $EPOCHSECONDS 
    1702812641
    1702812646

-- 
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462

Attachment: signature.asc
Description: PGP signature


Reply to: