I have a row in database table which has a value in seconds, which is how many seconds remains for premium membership to expire (it might be 1 month in seconds, or 25 days in seconds etc)
I am trying to make a script where if there are less than 30 days remaining, it will say for example,
25 d 14 h 45 m
or if its less than a day it will just say
14 h 45 m
and if it is less than an hour it will just say how many minutes remain. I tried to search in google for this but I didn’t know what to search for (search term).
Apparently you already have the “separate the time into units” part nailed, so here’s how to remove empty parts:
This will allow you to get things like “1d 0h 0m”, but not “0d 1h 2m”.