Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
tbjgolden723y@TechTech0 having lived in both US and UK the day month, month day thing causes so much hassle, ISO ftw
I set every date format to ISO now -
@ryios your shitty peace of code doesn’t even add the slashes. Dude holy fuck. You’re fired.
-
@ryios
MMddYYYY... that's illegal.
I would use
Date(isoDateString).toLocaleDateString(<preferred locale>, {year: 'numeric', month: 'long', day: 'numeric'})
Resulting in long-formatted "19 April 2019".
Why?
For machines, there are only 2 valid formats in my opinion: ISO and Unix.
For humans, fuck off with this dash vs slash and month-numbering-in-the-wrong place shit. Again, only 2 valid formats: Readable ("19 April 2019") and Relative ("Today" or "In 3 months").
What I usually do is the human thing for display, with an ISO date as a tooltip. -
@bittersweet For humans, ISO8601* is by far the best. I hate the other formats, they are so much harder to read. And please don't use that relative garbage. I hate it when it says "1 year ago".
*It does not really matter if there is a T or a space in the middle. ISO8601 requires a T but i don't care. -
bioDan61593y@happygimp0 if you dont care about timezones you'll get angry stupid users directly/indirectly breathing over your neck.
@bittersweet is absolutely correct. -
@bioDan I don't understand what this has to do with timezones, you can display IS8601 with or without timezone information.
-
TechTech0343y@yehaaw 😅
I had to explain to that guy, that we must avoid using ‘any’, otherwise TS is useless …
That’s how you should format a date in JS/TS!
rant
codebase
typescript
javascript