Nah man. Use 8601 for everything. They’re intrinsically chronologically sortable.
Or unix epoch time
Whenever I’m passing a date from a website backend to frontend I’ll usually send it inside something like
<span>
then have JavaScript convert it to a string based on the browser’s localization settings.So many websites I see for error reporting, etc always throw everything out as UTC and it drives me crazy. It would be nice to just have an HTML tag for ISO-8601 (or even UNIX as done here).</span>
Your prayer has been answered! Hear ye:
That looks like it’s only useful for machine-readable dates so it wouldn’t be useful for killing off the JavaScript portion of my “hack.” I cry at night for this
Looks like my code example glitched here. Basically a an HTML span tag with some CSS class for JavaScript to process.
In a programmatic context? Sure.
In an “I want to be able to comprehend this by glancing at it” context: absolutely not.
2023-08-10 15:45:33-04:00
is WAY more human legible than1691696733
.What, you don’t remember your time in Unix timestamps? Filthy casuls.
It’s super easy arithmetic too, just remember ”Pi seconds is a nanocentury.”
When I try to enter a date in excel and it formats it as numerical 424523 or some shit smh
ISO 8601 is amazing for data storage and standardizing the date.
Display purposes sure, whatever you feel like
But goddammit if you don’t use ISO 8601 to store dates, I will find you, and I will standardize your code.
I actually need to standardize my code. I’ve got “learning F2” as something I want to do soon. The goal: use the exif data of my pictures to create
[date in ISO 8601] - [original filename].[original file type termination]
So a picture taken the third of march 2022 titled “asdf.jpg” would become “2022-3-3 - asdf.jpg”
Help? lol
If you’re on Linux exiftool can get the creation date for you:
exiftool -p '$CreateDate' -d '%Y-%m-%d' FILENAME
, and you could run tgat in a loop over your files, something like:mkdir -p out for f in *.jpg do createdate=$(exiftool -p '$CreateDate' -d '%Y-%m-%d' "${f}") cp -p "${f}" "out/${createdate} - ${f}" done
Obviously don’t justbgo running code some stranger just posted on the internet, especially as I haven’t tested it, but that should copy images from the current directory to a subdirectory called ‘out’ with the correct filenames.
ok I think I finally need to ask
What the fuck is up with the html code? Ive seen this in a lot of posts and it just throws me every time.
I don’t see any HTML when I look at that comment from Lemmy, but kbin seems to make a real mess of rendering code blocks. Basically that bit had a few lines of code they could yse to do what they wanted.
Do you mean strings like
%Y
? They’re not url-encoded values - they’re strftime format directives.
I did this in the past and I would search through my notes… If I had notes ffs.
Can you give more context, what are you using? Language / system / etc?
I’m using NixOS. Ext4 filesystem. As to language, I’m not entirely sure what you mean. If you refer to the character set in the filenames, I think there are no characters that deviate from the English alphabet, numbers, dashes, and underscores.
Oh ok so you’re more so working with folder structure etc, so bash for when you plug-in a card?
I’m thinking in more programmatic terms, there’s definitely some bash scripting you can execute. Or just go balls out and write a service that executes on systemctl
epoch not acceptable then?
I will agree it’s a valid storage but it has to be specified in ms
Epoch is also acceptable if humans don’t need to understand it
Year-Month-Day best everywhere
Facts. The sorting system for files inevitably makes YYYY-MM-DD more optimal. I tried to resist but it doesn’t work.
To the commenters justifying the written form MM-DD-YYYY on the basis of preferring to say the name of the month followed by the day (which the written numerical sequence does not preclude you from doing). If someone were to say something like “the time is a quarter to eleven” do you think they would have a case for writing it 45:10? And if so, how would you deal with the ambiguity of “ten past ten” if they wrote it 10:10 instead of 10:10?
This is big pp idea and I like it.
Tab completion approves of this naming scheme.
ISO 8601 gang. You’d never want to describe dates that way but for file management the convenience is massive.
If you’re using a *NIX command line, something like
mkdir $(date +%F)_photos
is super handy.
I do. Anything I have to put a datecode on, always gets a stamp of YYYYMMDD.
That’s not ISO8601
That is the basic format of ISO8601, hyphens are only used in the extended format which is encouraged to be used in plain text.
See ISO 8601:2004 section 2.3.3 basic format
I’m definitely in the “for almost everything” camp. It’s less ambiguous especially when you consider the DD/MM vs MM/DD nonsense between US dates vs elsewhere. Pretty much the only time I don’t use ISO-8601 is when I’m using non-numeric month names like when saying a date out loud.
In Canada we use MM/DD and DD/MM so you never quite know which it is! There’s an expense spreadsheet I fill out for work that uses one format in one place and the other format in another…
That would ruin my entire day
Hey, that sounds like my cloud storage providers auto billing system.
“Your auto renewal will draft on 08/09/23.”
Is that August 9th or September 8th? Literally depends on where the person you ask is in the world.
Holy cats, that sounds like a nightmare.
Yeah, it’s pretty much everything for me too. The biggest exception being when UI is involved and a longhand date format would be more friendly.
Friendly to who?
The time reapers
And you can do a simple sort on the combined number and youve sorted by date.
Nah MMDDYY for me fam
I’m the same in my heart, but my brain says YYYYMMDD
You are objectively wrong.
It turns out I can label my files any way I like, thanks.
No, you can’t. Don’t bother locking the doors tonight, I’m coming in anyway.
The judge a few weeks later: “you did this because of WHAT?”
Reported
Yes, MM DD YY only makes sense when you’re speaking.
In written language it should always follow the order of smallest to largest, meaning day, month, and then year. Imo.
Though I personally try to use YYYY-MM-DD as much as possible in day to day life, if not applicable I use DD MM YYYY. YYYY-MM-DD of course doesn’t follow the order of smallest to largest, instead following the opposite order, though at least it has an order.
Largest to smallest is way more logical than smallest to largest. You start general and get more specific as you progress. It is in general a better approach to conveying information and cataloging data. Not just dates.
Yeah but if you’re communicating a date, then it’s likely that the larger chunks of time will match and can be ommitted, so it’s natural to go up the chain in until you hit the day/month/year that matches the current one. Although I guess that’d imply using minutes before hours… I guess you could go large to small and skip anything that matches too. Nvm lol
When does saying the month first ever help when you’re speaking? The month doesn’t change for like 30 days. The only thing that matters is dd which changes daily. If someone asks me what the date I’ll give them the day date and nothing else.
I don’t need to say it’s the 9th and watch them panic that maybe it’s January.
I don’t even know how to reply to this.
So if you made an appointment for the 2nd of September you’d tell 'em “yeah let’s meet on the 2nd” or “yeah let’s meet on the 245th” you’re gonna need the month somewhere.
Of course if it’s the same month it wouldn’t make a difference if you said “let’s meet on the 10th” or “let’s meet on the 10th of August” but if you’re making appointments for different months which in everyday life or in a work environment is not unusual you can’t just say “yeah the 2nd” and expect them to know which month. “Yeah you can expect delivery by the 4th”.
Tl;Dr:
I didn’t even say “it’s the only way to say it when speaking” I said “only makes sense when you’re speaking.” because in written form MM DD YY is just shit for everyone except Americans, to the point where context sometimes is the only saving grace. Vice versa applies.You only need to add the month if it’s not the current month. The same with the year.
Yep you’re 100% right. My job start date was miscommunicated because of this, they were like “you start on the 17th”… turns out it was the next month. Better than getting it wrong in the other direction though for sure!
Yes, MM DD YY only makes sense when you’re speaking
For many people it doesn’t. It’s something that’s exclusive to the US. In British English it’s day before month when speaking.
It’s something that is taught in school as “remember that the Americans say date before month so you don’t get confused”. But in a business context it’s bloody annoying you don’t switch to the international standard.
Yes, we also do days first in Germany.
Like I replied to someone else in this thread: I wasn’t saying “it’s the only way that makes sense when speaking” I said “it only makes sense when speaking”. That doesn’t make any other way of saying dates make less sense when speaking though.
Preach!
The dashes waste space. You’ll know what 20230809 means in context.
i’ve seen some software use . although that’s less human-readable than -. i hope you still use 8.3 naming on everything if you’re complaining about two hyphens.
Wrote it on another comment, this way it loses human-readable a bit.
I saw these with hh:mm:ss all without keystrokes. That’s the worst.
This is me but without the dashes. Haha I know l, what’s wrong with me…
But I’ve also started using 10/Aug in emails to make things crystal clear.
Anyway.
yyyy-mm-dd makes it much clearer about what fucking order things are in
Yeah if the day of the month is less than 12 and any other format is used it becomes a guessing game.