I'm trying to convert two Epoch (Unix timestamp) dates to human readable date (time left)
AT=$(echo $RES | jq '.results[0].unixtime' | tr -d '"') # Returns unix time in JST.
NOW=$(TZ=":Asia/Tokyo" date +%s) # Returns current time in JST
DIFF=$(echo $AT-$NOW | bc)
As an example;
AT=1470038400
NOW=1470032871
DIFF=5529
How do I get the remaining time between the two in the following format: DAYd HOURh MINm SECs?
您可以尝试以下
printf "%dd %dh %dm %ds\n" $(( DIFF / (3600 * 24) )) $(( (DIFF / 3600 ) % 24)) $(( (DIFF / 60) % 60)) $((DIFF % 60))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.