coreutils
[Top][All Lists]
Advanced

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

Re: How to calculate date relative to another date?


From: Steeve McCauley
Subject: Re: How to calculate date relative to another date?
Date: Wed, 22 May 2019 06:44:40 -0400

--iso seems to be an undocumented equivalent to the --iso-8601 date format,
that gives you YYYY-MM-DD as the default format.

You seem to have fallen on a bug in that either,

1) date string is corrupt and doesn't emit an error
2) date string is correct but fails to generate a correct result

According to the man page it is fully documented in the "info"
documentation.  From what I can tell the more complex relative date string
(4 years 11 months ago) is not supported,

https://www.gnu.org/software/coreutils/manual/html_node/Relative-items-in-date-strings.html#Relative-items-in-date-strings

It would be pretty awesome if one could specify "4 years 11 months 3 days 4
hours and 7 minutes ago" but that seems not possible.  In your case I also
tried "4 years 11 months from 2018-05" but that just failed.




On Tue, May 21, 2019 at 9:17 PM Peng Yu <address@hidden> wrote:

> > Seems to work fine when date specification is not quite as ambiguous
> > as "2018/05".
> >
> > $ date --iso --date='2018-05-01 5 years ago'
> > 2013-05-01
>
> What is special about --iso? If I use the following date string, I get
> a future time. Why?
>
> $ date --date='2018-05-01 4 years 11 months ago' +%Y%m
> 202106
>
> --
> Regards,
> Peng
>
>

-- 
:wq


reply via email to

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