On Mon 18 Dec 2023 at 01:11:26 (+0000), Albretch Mueller wrote: > On 12/18/23, David Wright <deb...@lionunicorn.co.uk> wrote: > > When you write dt00=$(date +%Y%m%d%H%M%S) > > that's /your/ format, not coreutils'. > > I (erroneously?) thought coreutils was maintaining Linux date, so if > they tell you on their --help instructions to use certain options > (including cobbling them together to your heart's content) and you are > telling them you are using their format and how, they should be able > to parse that string.
You can prettyprint a timedate with date any way you care to, but scanning a timedate with --date requires care. It's safest if you give it a string in one of its own built-in formats. You appear to be expecting your second date command to somehow guess the format you used in the first command, which obviously can't happen. Another problem in what you posted is that you sometimes run date in your local timezone (generally for the "now" times), but you append +00:00 as the timezone for those --date strings that you construct from several substrings. You need to use UT throughout. > ANyway, my hack around it wasn't effortful at > all. I don't know whether you're referring to something already posted, or some new script written in the wake of what you've read here. Cheers, David.