[Cialug] Calculating dates relative to today

kristau kristau at gmail.com
Fri Mar 1 22:09:11 UTC 2024


+1 for brevity. Nice!

On Fri, Mar 1, 2024 at 1:55 PM Shane Nehring <shane at ntoast.com> wrote:

> This can also be done with the date command:
>
> snehring at mamizou:~$ date -d "+90 days"
> Thu May 30 14:44:07 CDT 2024
>
> On Fri, Mar 1, 2024 at 12:40 PM kristau <kristau at gmail.com> wrote:
>
> > Just discovered this nifty command-line hack to calculate dates relative
> to
> > today instead of using some random date-calculating website or counting
> > squares on an old fashioned wall-hanger:
> >
> > touch -d 'X day' test; stat test
> >
> > Examples:
> >
> > *90 days from today?*
> > kristau at pop-thelio:~$ touch -d '90 day' test; stat test
> >   File: test
> >   Size: 0               Blocks: 0          IO Block: 4096   regular empty
> > file
> > Device: fc01h/64513d    Inode: 46138998    Links: 1
> > Access: (0664/-rw-rw-r--)  Uid: ( 1000/ kristau)   Gid: ( 1000/ kristau)
> >
> > *Access: 2024-05-30 13:30:47.677889558 -0500Modify: 2024-05-30
> > 13:30:47.677889558 -0500*
> > Change: 2024-03-01 12:30:47.677657453 -0600
> >  Birth: 2024-03-01 12:30:25.265369754 -0600
> >
> > *90 days ago?*
> > kristau at pop-thelio:~$ touch -d '-90 day' test; stat test
> >   File: test
> >   Size: 0               Blocks: 0          IO Block: 4096   regular empty
> > file
> > Device: fc01h/64513d    Inode: 46138998    Links: 1
> > Access: (0664/-rw-rw-r--)  Uid: ( 1000/ kristau)   Gid: ( 1000/ kristau)
> >
> > *Access: 2023-12-02 12:32:53.049962148 -0600Modify: 2023-12-02
> > 12:32:53.049962148 -0600*
> > Change: 2024-03-01 12:32:53.047266778 -0600
> >  Birth: 2024-03-01 12:30:25.265369754 -0600
> >
> > Might not be new to you, but it was new to me so I thought I'd share!
> > --
> > Tired programmer
> > Coding late into the night
> > The core dump follows
> > _______________________________________________
> > Cialug mailing list
> > Cialug at cialug.org
> > https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
> >
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
>


-- 
Tired programmer
Coding late into the night
The core dump follows


More information about the Cialug mailing list