2021-11-21 15:10:35
See how much easier that is?
irb> puts “2021-11-21\r\t15:10:35”
2021-11-21
15:10:35RFC 3339 notes:
NOTE: ISO 8601 defines date and time separated by "T".
Applications using this syntax may choose, for the sake of
readability, to specify a full-date and full-time separated by
(say) a space character.
I tend to use the space whenever possible.Note also that ISO 8601 doesn't require the "T" to be uppercase. A lowercase "t" might be slightly more readable: 2021-11-21t15:10:35
Not that avoiding such names solves the problem, it just makes the RCE vulnerability more latent.
I had to fix so many of these in various databases and frontends, lol
A website/app shouldn't have to find your timezone. It should use whatever one you've set. If you've set your timezone to one you didn't want, I'm not sure what you'd expect other software is meant to do about that. Fix your config.
Even if the user set it in one time zone, if we store it without a proper offset (and preferably a locale), we cannot properly account for the user traveling to another place, daylight savings time, government time adjustments, leap time, etc. These complexities compound off each other and make proper scheduling and debugging time issues really, REALLY hard later on.
In the twenty years or so that I've been doing web dev, datetime is probably the single biggest gotcha I've seen developers (including myself) stumble into. Part of this is because the standard JS datetime handling is atrocious compared to any other language I've worked in. It doesn't really natively handle time zones well, and well carelessly cast them back and forth if you're not careful.
Moment and Luxon can help with this, lighter libs like date-fns can too with the right extensions, but out of the box JS is going to fuck it up. I promise. Another choice is to just use milliseconds to store everything, and convert that to the user's timezone only at the time of display. Every timestamp is stored as an epoch, and every user has their time zone (not just offset, because of daylight savings) recorded with their profile. Doing those two simple things can avoid most of the landmines.
And javascript natively converts epoch time to whatever timezone the client has set. If your user-agent (aka browser) is working on New York time, but you're in Tokyo, well, I'm not sure who else you have to blame but yourself if it shows you New York time when you didn't want that.
Then it doesn’t matter if you write it
November 12 2012
2012 November 12
12 November 2012
2012 12 November
Etc.
How would 2012 ноябрь 12 feel to you?
But I don't mean to pick a Star Wars / Star Trek fight: I'm bistellar, I love both of them!