[Cialug] Calculating dates relative to today

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


OK, that sent me down a bit of a rabbit hole:

kristau at pop-thelio:~$ date -d "1 Jan 2024 16:21:42"
Mon Jan  1 04:21:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42')"
Mon Jan  1 04:21:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42') +10 days"
Thu Jan 11 04:21:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42') +10days"
Thu Jan 11 04:21:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42')
+10days7hours"
Thu Jan 11 11:21:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42')
+10days7hours23minutes"
Thu Jan 11 11:44:42 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42')
+10days7hours23minutes18seconds"
Thu Jan 11 11:45:00 PM CST 2024
kristau at pop-thelio:~$ date -d "$(date -d '1 jan 2024 16:21:42')
+10days7hours23minutes19seconds"
Thu Jan 11 11:45:01 PM CST 2024

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