help-bash
[Top][All Lists]
Advanced

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

Re: EPOCHREALTIME to days, hours, minutes, seconds


From: Tapani Tarvainen
Subject: Re: EPOCHREALTIME to days, hours, minutes, seconds
Date: Fri, 20 Aug 2021 16:34:20 +0300

On Fri, Aug 20, 2021 at 12:22:21PM +0000, hancooper (hancooper@protonmail.com) 
wrote:

> > now=$EPOCHSECONDS
> > printf -v seconds '%(%S)T' "$now"
> > printf -v minutes '%(%M)T' "$now"
> > printf -v hours '%(%H)T' "$now"

> How can I deal with seconds that includes fractional part ?

The Gnu date -based solution I posted earlier deals with them,
but the above can be modified to do it as well:

now=$EPOCHREALTIME
printf -v seconds "%(%S)T.${now#*.}" "${now%.*}"
printf -v minutes '%(%M)T' "${now%.*}"
printf -v hours '%(%H)T' "${now%.*}"

-- 
Tapani Tarvainen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]