46
19
u/decimated_napkin Jul 09 '19
unix timestamp or gtfo
2
u/_westernmagic Jul 09 '19
Which cannot represent leap seconds
3
u/cbarrick Jul 10 '19
You don't need leap seconds in Unix. It's just the number of seconds elapsed since the epoch. It's always unambiguous. You only need to consider leap seconds when converting to a format that cares.
-1
Jul 09 '19
Seriously. There is only one machine readable perfectly transformable date standard and this is it.
19
17
u/kominetz Jul 09 '19
You know nothing, Femi Lee.
There is ISO-8601. Anything else is irrelevant. There can be only one (correct date format).
XKCD agrees: https://xkcd.com/1179/
5
5
13
u/dudeasaurusrex Jul 09 '19
DDMMMYYYY (eg. 09JUL2019) is never ambiguous and the order of the elements is small to large.
YYYYMMDD if you need it sortable as a character string.
6
0
u/Khashoggis-Thumbs Jul 09 '19
Pandas will read anything in so long as the format is known. It is inconsistent and ambiguous data that requires some detective work.
5
u/postal__dude Jul 09 '19
At a performance cost for large data amount. Take the example of fread() from Data.table in R. Fast as hell but parses dates as chars. I benchmarked the process of importing via read.csv2() with date format vs fread() and seperate date parsing and the fread() was way quicker
3
u/Khashoggis-Thumbs Jul 09 '19
I also find separate date parsing in python faster than specifying a parser besides str for pd.read_csv()
1
1
1
u/MelonFace Jul 09 '19
ITT: People who never had to deal with third party data from different time zones.
A datetime is not a datetime before you have it's time zone.
And as if that is not enough, there are some countries that turn the clock back an hour during winter.
2
2
1
Oct 23 '19
YYYY/MM/DD is better. Numbers are typically sorted by the biggest digits first, so why don't we do the same for dates?
0
u/Proto_Ubermensch Jul 12 '19
MM-DD-YYYY
It matches the way we say it. March 15th, 2019
Who the fuck says 15th march, 2019?
2
u/postal__dude Jul 12 '19
Bro, not everybody in the world speaks English ! In French for example we say "Le 15 Mars 2019" And all French/European systems use the DD-MM-YYYY format.
0
u/Proto_Ubermensch Jul 13 '19
English is the dominant global language of business. As evidenced by the fact that we're on Reddit using english not french.
GG no RE.
0
u/mailfriend88 Jul 09 '19
A nice silent candlelight dinner with my most loved person! a perfect date!
0
Jul 09 '19
[deleted]
101
u/blaze_firestormer Jul 09 '19
I even like it as YYYYMMDD.
45
u/Aesthetically Jul 09 '19
In string type this is the master date format in my opinion. Easy to parse this out and convert it to any desire format. No dashes slashes or any crap to worry about, string type, and the bigger unit always comes first for quick sorting.
23
u/jackmaney Jul 09 '19
As a bonus, you can even store it as an integer.
15
u/DuffBude Jul 09 '19
Just don't increment it..
1
u/jackmaney Jul 09 '19
Yeah, that's really about the only caveat to storing dates that way. It's easy enough to write a function or wrapper around whatever date class you're using that does the incrementing correctly.
1
5
u/Aesthetically Jul 09 '19
And integers are lower memory right?
13
u/jackmaney Jul 09 '19
Yeah, an eight character string takes eight bytes (assuming we're not using a weird encoding like UTF-16) whereas a 32 bit integer only takes up four bytes. Also, integer comparisons are generally quicker than string comparisons.
5
u/Trxisj Jul 11 '19 edited Aug 23 '19
All programming languages, libraries, system utilities, and just about anything you’ll ever use should sort YYYY-MM-DDThh:mm:ss (and similar) exactly the same as YYYYMMDDhhmmss. All dates similar to that - which are considered ISO 8601 dates / datetimes - are naturally lexicographically sortable.
The only difference between YYYY-MM-DD and YYYYMMDD is the first is way more human-readable, which is why it should always be preferred over the un-delimited one, IMO. Code is for humans to read, not machines. I’d also say it’s much easier to parse out with the delimiters than without. If you’re ever in a situation without native ISO 8601 parsing, you’d probably not prefer looking at 20131113141341 compared to 2013-11-13T14:13:41. You can quickly glance at the latter and immediately understand it. Sure, you’ll obviously still be able to interpret the un-delimited one, but it’s going to take more time. If you’re looking at a ton of dates, that time can add up. I’ve been in debugging situations where I have to look at a bunch of files like:
20152115146121.csv 20131133141341.csv 20132513262452.csv 20142141579449.csv 20122943594418.csv 20182313179436.csv 20144163929251.csv 20191845412338.csv 20134193144619.csv 20142921594531.csvtimes 1000. It’s an eye sore, especially if the task requires you to pay closer attention to the less significant digits than the more significant ones. And if the numbers are in a small font and aren’t displayed with much padding, they can even kind of mentally blend together a little.
We already have a readable, naturally sortable, standard format most technologists and systems have agreed on since 1988; why not use it?
2
u/Aesthetically Jul 11 '19
You pose great points and have convinced me the delimited version is better.
Doesn't change the fact our enterprise uses the non delimited format for fiscal dates :/
-1
u/remram Jul 10 '19
It's also the one that's not confusing, @femscie is wrong. Both MM/DD/YYYY (USA) and DD/MM/YYYY (everyone else) are used, but no one uses YYYY-DD-MM.
1
9
Jul 09 '19 edited Apr 21 '26
[removed] — view removed comment
1
u/Aesthetically Jul 09 '19
Luckily 0 padding the month and day values is input controllable for my use cases.
2
4
32
u/wintermute93 Jul 09 '19
Ddmmyyyy might be more intuitive to read but yyyymmdd has the not insignificant advantage of alphabetical sort = chronological sort.
29
6
0
Jul 09 '19
[deleted]
8
Jul 09 '19
No, it’s a weird format. Most people use the YYYY-MM-DD format as it’s what most of Asia uses. Plus it’s the easiest to read.
2
-3
u/jackmaney Jul 09 '19
Only if you would say, eg, "the ninth of July, 2019" instead of "July ninth, 2019". The latter phrasing is far more common in the US.
2
u/wintermute93 Jul 09 '19
Do you also say $5 as "dollars five"?
-2
u/jackmaney Jul 09 '19
Nope, and the vast majority of Americans wouldn't either. Your point?
3
u/wintermute93 Jul 09 '19
My point is that the way a formatted number is written (like a date/time or dollar amount) is irrelevant to the way it's pronounced, obviously.
0
u/jackmaney Jul 09 '19
Depends on whether, eg, the dollars are US, Canadian, etc. :)
0
u/wintermute93 Jul 09 '19
But that's exactly my point. The fact that how formatted numbers are written vs spoken matches up in some languages but not in others is proof that in general the two are independent of each other. Therefore, the way we say dates aloud shouldn't dictate how we write timestamps.
0
u/onahotelbed Jul 09 '19
Who cares how you say it, though?
-1
u/jackmaney Jul 09 '19
For that matter, who cares how you say it?
1
u/onahotelbed Jul 09 '19
?
The point is that the date format and the way it's spoken aloud don't really need to be the same.
-1
u/jackmaney Jul 09 '19
Yes, hence the yyyy-mm-dd format. Again, do you have a point?
1
u/onahotelbed Jul 09 '19
What in the fuck is going on. The comment to which I replied - your comment - says that dd-mm-yyyy makes no sense because it isn't aligned with what's spoken aloud. My point has been made several times, you're just an idiot.
I've literally never seen someone so worked up about something so trivial, go drink a Monster and chill out, Kyle. It's not a big deal.
-1
u/jackmaney Jul 09 '19
My point has been made several times, you're just an idiot.
Aaaand there's a report for targeted harassment.
I've literally never seen someone so worked up about something so trivial
LOL it's amusing that you think I'm "worked up" over this.
1
u/onahotelbed Jul 09 '19
"I'm not worked up, but I am reporting you, because I feel victimized"
-1
u/jackmaney Jul 09 '19
LOL And there you go again assuming that I feel a certain way. If you can read my mind, then tell me the number that I'm thinking of. Hint: It's between one and one billion.
→ More replies (0)-1
u/insearchofansw3r Jul 09 '19
Sadly yes but the day month year format feels legit
8
u/jackmaney Jul 09 '19
...to you, perhaps.
MM-dd-yyyyfeels just as legit to me. However,yyyy-MM-ddis the superior date format.1
u/insearchofansw3r Jul 09 '19
Genuine question why superior
12
u/NowanIlfideme Jul 09 '19 edited Jul 09 '19
Never ambiguous, sorting order is the string order and chronological order at the same time. You got the "most significant" numbers on the left always. You can add a timestamp at the end easily and keep this property. ISO standard 8601 is the more formal way to do this format, but for day-to-day stuff I use YYYY-MM-DD hh:mm:ss or a left substring, depending on the accuracy I need. Even in real life. Saves on ambiguity and thinking time. ;)
2
457
u/Yojihito Jul 09 '19
ISO 8601 - YYYY-MM-DDThh:mm:ss.sTZD
Fight me!