On Friday, 20 January 2017 at 03:48:14 UTC, rikki cattermole wrote:
On 20/01/2017 9:29 AM, Rene Zwanenburg wrote:
On Thursday, 19 January 2017 at 14:04:36 UTC, aberba wrote:
Using the standard library, how do a get number of hours or seconds or minutes or days or months or years till current time from a past timestamp (like "2 mins ago")? Not with manual calculations but from
Phobos functions.

You can get a duration by subtracting two timestamps. For example:

auto delta = (Clock.currTime - timeStamp).total!"seconds";

As per the documentation this is wrong for anything beyond a few weeks.
Although I have no idea if that's the case implementation wise.

Actually I want a weak approximation. So 1 yr 6 months will be recorded as 1yr or better still the actually date. Just want to make it easy to determine "how long ago" for all recent data at client side.

Reply via email to