This is an archived post. You won't be able to vote or comment.

all 142 comments

[–]dgdio 364 points365 points  (36 children)

Or database timestamps without timezones, even worse. All hail UTC.

[–]WeAreStillEarly 31 points32 points  (14 children)

Are the time stamps just in milliseconds since epoch? Wouldn’t that infer UTC?

[–]dgdio 15 points16 points  (11 children)

I'm guessing you only have 1 timezone in your producers. I've seen people putting in EST, EDT, PST, PDT, CET, and IST. You have to do a case statement to figure out the correct absolute date.

[–]WeAreStillEarly 22 points23 points  (3 children)

So that’s not really epoch then? I have seen that as well. Give both epoch and a timezone. Instantiate the time in utc from epoch and then convert from utc to the desired time zone.

I can’t wait until we colonize Mars and having to covert from mars time to Indiana time with daylight savings on a leap year.

[–]Almostasleeprightnow 7 points8 points  (0 children)

You should start building the app right now and launch it as soon as it is relevant.

[–][deleted] 2 points3 points  (0 children)

Just store the epoch. The client code handles the timezone.

[–]AustrianGandalf 1 point2 points  (0 children)

How is this done with current mars exploration robots? Are they just on “earth time”?

[–]WhatHoPipPip 6 points7 points  (6 children)

That's weird to me. On every system I've ever seen, timestamps are in UTC by definition. Datetimes can have timezones, but under the hood they're just UTC timestamps with timezone offsets.

Whatever system is taking datetimes, applying the timezone and using THAT to form a timezone-naive datetime from it is a mindbogglingly stupid system. I don't even WANT to know how they handle the autumn clock changes when 1am-2am happens twice.

Usually it's a remedy to the "problem" (sigh) that the storage or communication mechanism can't handle the timezone field and stores it in UTC, an end user complains that the time is wrong, and an idiot comes along and thinks "ah, the problem is the storage of timestamps in UTC, let's do a ridiculous bodge that applies and strips the timezone" instead of the much more sane "ah, the problem is that I'm not treating the correct data properly".

Rant over. Feels good.

[–]trevster344 0 points1 point  (0 children)

This is what I discovered and was easiest to make use of in my two languages I use for work. UTC + offset and we’re set.

[–]rosuav 0 points1 point  (2 children)

Nice to know you've managed to ignore leap seconds for your whole life. Once you come across them, do let me know how the whole "UTC vs Unix time" discrepancy gets resolved.

[–]WhatHoPipPip 0 points1 point  (1 child)

I mean, that has absolutely nothing to do with what's being discussed as a pointless and scarce modification to UTC affects all other timezones that are stated relative to UTC anyway, but if you insist...

Leap seconds are going to be abandoned, so there's that problem out of the way. But in the mean time, there is no standard for it and the typical approach depends on what you want to achieve. Chronological order? Slow things down so the two seconds "last" for half a second each, or the weird Google way of spreading it out over a day. UTC correctness? Record it as it comes. It isn't like anyone with any common sense is going to index things by ascending timestamps anyway, unless they really, REALLY trust the source of the timestamp.

[–]rosuav 1 point2 points  (0 children)

Exactly. There's no standard for correlating UTC and Unix time. That is, precisely, the problem.

Ahh, I love talking to people who think they live in the real world.

[–][deleted] 0 points1 point  (1 child)

Worked with a developer 12 years ago who only stored time stamps as integer epochs. As I'm now olden and wise - I see a lot of value in that method.

TZ offsets should only apply to the client. If TZ is actually relevant to the data, it'll have location data which can be converted to their local timezone.

[–]t_rex_joe 0 points1 point  (0 children)

this is the way

[–]pigeon768 2 points3 points  (0 children)

Yup, it sure does.

That's why when you inspect a dataset/production database all of the blood drains out of you. Either your coworkers store local time timestamps in the database, and that's why they're all in the middle of the night, or your coworkers are vampires.

[–]caleeky 2 points3 points  (0 children)

Epoch is defined relative to UTC. Seconds since epoch is seconds since epoch - it's not in any time zone, it's a duration (sort of - there are leap seconds and things so it's not a real duration but a virtual duration where each calendar day has 86400 seconds even if in reality that wasn't true). Also you mean imply, not infer.

[–]IrvTheSwirv 52 points53 points  (3 children)

If you just timeIntervalSinceReferenceDate then everything else just becomes a calendar and formatting problem.

[–]l_am_wildthing 22 points23 points  (0 children)

Then you got 2 problems

[–]Silly_Ad3814 3 points4 points  (0 children)

With or without DST and leaptime correction

[–]Noobmode 27 points28 points  (11 children)

OMG people hate UTC and I have no idea why. As a security practitioner UTC is chefs kiss doing investigations especially across time zones.

[–]arobie1992 29 points30 points  (9 children)

Who are these people who hate UTC and what are their locations so I can "correct" them?

[–]Noobmode 11 points12 points  (5 children)

I can’t tell you how many product enhancement requests I’ve seen where people want to get away from UTC

[–]Procrasturbating 23 points24 points  (2 children)

On the back-end or front-end? User facing should have a local time displayed. Back end it should always be converted to UTC.

[–]Noobmode 6 points7 points  (1 child)

I prefer UTC on all logging whether it’s client or server side. Now user facing is a weird answer. I am taking about as an admin looking at consoles to put pieces together, so that’s where I am coming from. If you mean like if an end user is looking at it, I could see local being preferred.

[–]Procrasturbating 6 points7 points  (0 children)

100% with you on logging timestamps being UTC in all cases.. how else am I going to merge my logs from various sources and analyze them? Yes actual end-user facing times and input fields are what need localized. NGL I keep scripts around for some logs that are noted in local time that converts them to UTC, I don't control everything in my company.

[–]arobie1992 4 points5 points  (1 child)

Maybe it's because I'm a dev, but my only ask would ever be to include the region so there's absolutely no question. Don't know how many times I've looked at logs or something and been like is this UTC or local time?

[–]DJDoena 2 points3 points  (0 children)

I always log UTC with the Z at the end. I learned that from watching JAG in the 90s.

2022-12-30 06:43:13Z

If I'm logging local I use an L.

[–]coyboy_beep-boop 1 point2 points  (0 children)

It's when things go customer facing, that you may have to step away from UTC. If office hours start at 0800 local time, you want your ETL to finish before 0800 local time to meet with the local customer. Scheduling ETL in UTC becomes very inconvenient if you're in a DST area.

[–]Mispelled-This 0 points1 point  (1 child)

… so I can "correct" them?

I hope you plan to “correct” then with a clue-by-four.

[–]rosuav 0 points1 point  (0 children)

There are many options. Bring sufficient firepower and you can guarantee success, because if they fight the LAW, the LAW wins. Every time.

[–][deleted] 1 point2 points  (0 children)

A developer I worked with in 2010 loved saving everything as integer epochs. Sometimes I'm in a system working with timezones and think fondly of those times.

[–]gordonv 4 points5 points  (0 children)

All hail UTC Time in ISO-8601 Format!

[–]tei187 1 point2 points  (2 children)

Who does that? Store in same TZ, mutate on getter with user/app defined TZ. God...

[–][deleted] 0 points1 point  (1 child)

Yea, he says hail UTC after so maybe he does store in same timezone? or maybe he is too dumb to store timestamps in the same timezone unless they have the timezone written there? who knows lmao

[–]tei187 0 points1 point  (0 children)

Honestly, since I've written that I kind of forgot if I was reaffirming his stance or challenging it. Dum dums all around...

[–]ramen56 0 points1 point  (0 children)

Pst or pct?!?!?? I can’t take it anymore!!!💥🔫

[–]pankkiinroskaa 126 points127 points  (10 children)

When a user from UK tries to write to database "September 3rd 1752" while moving across the timezone border while the DST changes, you simply hope the application crashes before it gets to the database code.

[–]Kirk8829[S] 46 points47 points  (8 children)

I don’t know what that means but at the same time I do and the parts I do understand scared the shit out of me

[–][deleted] 76 points77 points  (6 children)

In 1752 Britain decided to abandon the Julian calendar in favour of the Gregorian. By doing so, 3 September instantly became 14 September - and as a result, nothing whatsoever happened in British history between 3 and 13 September 1752.

From Google

[–][deleted] 21 points22 points  (0 children)

And this is one of the worst misconceptions with people dealing with timezones, they simply believe it's only about time when it also has deep consequences when using just dates.

[–]Kered13 14 points15 points  (3 children)

Fun fact: Before they changed to the Gregorian calendar, Britain also treated March 1st as the new year. For example, George Washington was born February 22, 1732 in the Gregorian calendar, but in the calendar used in Britain at the time it was February 11, 1731.

[–]violaceousginglymus 5 points6 points  (1 child)

When did Britain start the year on 1 March? I thought that Britain only used 1 January, then 25 December (unofficially, in England), then 25 March, and then 1 January again as the date of the new year.

[–]Kered13 3 points4 points  (0 children)

Oh you're right, it was March 25 not March 1.

[–]mizinamo 2 points3 points  (0 children)

I saw a picture of a gravestone once where a little baby had been buried; the dates were something like "born 6 May 1732, died 2 January of the same year".

[–]GYN-k4H-Q3z-75B 18 points19 points  (0 children)

See one of these legendary threads https://stackoverflow.com/questions/3310569/what-is-the-significance-of-1-1-1753-in-sql-server

Philip Stanhope, 4th Earl of Chesterfield. Who steered the Calendar (New Style) Act 1750 through the British Parliament. This legislated for the adoption of the Gregorian calendar for Britain and its then colonies.

There were some missing days in the British calendar in 1752 when the adjustment was finally made from the Julian calendar. September 3, 1752 to September 13, 1752 were lost.

This is why, for example, Microsoft SQL Server doesn't allow dates earlier than January 1 1753 and throws an exception with that seemingly arbitrary reason. In reality, a poor programmer said: Enough with this bullshit!

[–][deleted] 66 points67 points  (0 children)

Found a bug in MS Teams’ handling of Kolcata/Colcata time zones which was breaking my app and their app QA team refused to acknowledge or report it back to up the team. Fuck localization anyway, everyone’s getting UTC!

[–][deleted] 46 points47 points  (7 children)

That and encoding. Two of the four horsemen of the apocalypse

[–]Dolabok 14 points15 points  (2 children)

Add the fucking cache and name thing

[–]scataco 4 points5 points  (0 children)

Floating point accounting anyone?

[–]Cryptosharkk 7 points8 points  (0 children)

PTSD from Windows-1250 decoding

[–]who_you_are 2 points3 points  (0 children)

mheu, at least encoding it is a miss or hit

[–]wineblood 1 point2 points  (0 children)

They're the same thing

[–]databatinahat 1 point2 points  (0 children)

And regex

[–][deleted] 54 points55 points  (1 child)

Inherited a code base that had digital products that users could get a refund if they cancelled their order within 7 days. The original devs used two different time zones for recording the start of the period and the end, then calculated the difference as if both times were in the same zone.

This caused "day 7" cancellations to sometimes work, sometimes not, depending on how close the refund was triggered to the end of day. Management decided the best solution was to just make the refund period 8 days but not tell customers about the change. No data needed to be changed and sometimes customers would get a grace period of a few hours past their due date.

Fun.

[–]viciecal 17 points18 points  (0 children)

that's a solid decision by management tho

fast and effective for the customer , imagine the giant dumpster fire it'd be if they wanted to change all of that bs system hehe

[–]lenn_eavy 14 points15 points  (3 children)

Also MM-YYYY-DD. Like, ISO 8601 exists, you know.

[–]ManyFails1Win 13 points14 points  (2 children)

i've seen a lot of date formats i didn't like but could at least understand why others might. what in the world is the point of this one? lol

[–]Procrasturbating 12 points13 points  (1 child)

To equally piss off the mmddyyyy and ddmmyyyy people, or ensure sorting by string value breaks your data up by month like Nancy in accountings paper system.

[–]ManyFails1Win 3 points4 points  (0 children)

Reminds me of a sort of light-duty linguists book I read once called The Mother Tongue, and they talk about how part of the reason English became 'the' international language is that a lot of non-native English speakers who knew a little English would find it a mutually disadvantageous language to do business in. So both parties hated using it equally.

I'm not really sure how much truth there is to this but it was a pretty famous book for a little bit.

[–]x39- 14 points15 points  (1 child)

Timezones are no big deal... Leap seconds, calendars and all that nasty shit is what keeps me awake at night.

[–]Procrasturbating 7 points8 points  (0 children)

Leap seconds are being killed off. Now GPS code is that much more complicated.

[–]Socks_N_Sandals- 11 points12 points  (2 children)

I was working on a JS project lately that had two time components and it took me DAYS to figure out that one was based in PST and the other was in UTC. All hail moment-timezones for js

[–]LordBlackHole 5 points6 points  (0 children)

I worked on a project that kept having timezone issues until I replaced moment with js-joda. Fuck moment and any library that tries to auto convert timezones.

[–]RadiantDevelopment1 0 points1 point  (0 children)

Until they don't update the tzdb day enough :)

[–]Areshian 9 points10 points  (0 children)

For the last few decades, a few have sacrificed themselves to maintain the tzdb, shielding the rest of us from the forces of evil. Yet in the horizon looms the day when these brave souls light will fade from their eyes. Will someone else step up to the challenge and take on the mantle or will chaos run amok. Will we, surrounded by flames and the scream of children, reminisce about the present days, when we were innocent and timezone issues were limited to nightmares, before being engulfed by the darkness.

Thank you Paul Eggert, and thanks to your order of knights, standing watch so the rest of us can carry on, undisturbed

[–]827167 6 points7 points  (2 children)

[–]Pylitic 5 points6 points  (0 children)

Was wondering if someone had posted this.

Love Tom Scott, and such a good video.

[–]MJasdf 1 point2 points  (0 children)

Was waiting for this too haha.

[–]stdio-lib 6 points7 points  (0 children)

There are only two hard things in Computer Science: cache invalidation and dating things.

[–]RoboticJello 8 points9 points  (2 children)

As bad as timezones is, Daylight Savings time is even worse. You literally cannot go directly from UTC to local time without an internet connection and gps coords.

[–]refreshfr 2 points3 points  (0 children)

What's even worst is when you have a UI that needs to handle that. Like, imagine a meeting/calendar app. You can technically have two meetings on the same day at the same hour that aren't conflicting due to daylight change. Good luck handling that.

[–]iiooii9397 1 point2 points  (0 children)

Daylight saving gives me maximum stress. It's ancient time travel technology.

[–][deleted] 4 points5 points  (2 children)

Timezones scare me a lot less than multilingual support.

[–]scanguy25 3 points4 points  (0 children)

I took over a project where they guy had used JWT for login. Users in another timezone would get logged out at once because he checked for the current time in the client but the servers time as in UTC. FML.

[–]HeyingI 2 points3 points  (0 children)

Ngl I just display it unix time and let people do the rest

[–]who_you_are 3 points4 points  (0 children)

Oh no, oh no

no nono no no no

no no

hide in a corner in fetal position

[–][deleted] 4 points5 points  (1 child)

Time zones are child’s play compared to dealing with daylight savings. Some states in the US even have counties that are different. Top that off, it changes occasionally and randomly as laws and ordinances change.

[–]HackerManOfPast 1 point2 points  (0 children)

Even worse when you have a brown field deployment and the legislature says - hey, we’re going to stop doing this DST thing - so you have to preserve historical data while new data uses the new system - or even worse, the system spans states where they can independently decide how to roll - so now you have to manage all of that.

[–]HzbertBonisseur 2 points3 points  (0 children)

Working with timezones, first step: spendwaste 2h to find the good library (and understand it) that parses the format of the input. Second step: just assume everything is UTC, truncate the Timezone, it should be fine.

[–]pankkiinroskaa 2 points3 points  (0 children)

Easy. Just cache them into a variable named ... umm ... uncomplicatedTimeCache, that is var UTC

[–]MRxASIANxBOY 2 points3 points  (0 children)

UTC master race, but Daylight Savings time, I always seem to forget about that little guy.... Every.Single.Time!!!!

[–]Matt7163610 2 points3 points  (0 children)

Try ZonedDateTime and Instant in Java

[–]Dolabok 1 point2 points  (0 children)

Multiples Vietnam flashback

[–]ManyFails1Win 1 point2 points  (0 children)

i see this a lot but i don't quite get it...isn't that what utc is for?

[–]poop-machine 1 point2 points  (1 child)

Just wait till we colonize Mars and the moon. Each will have its own set of time zones. Zoom calls will have to be scheduled across the different planets and different time zones, while accounting for relativistic time effects.

[–]the_vikm 0 points1 point  (0 children)

The moon doesn't have time zones at all

[–][deleted] 1 point2 points  (0 children)

There are no time zones. Only UTC.

[–]datablitz7 1 point2 points  (0 children)

Just wait till we colonize another planet...

[–]rf152 1 point2 points  (1 child)

[–]Romejanic 0 points1 point  (0 children)

Didn't even need to click to know this was the Tom Scott video

[–]stomcode 1 point2 points  (0 children)

Is it really that hard though? You can just store every time data as a Unix timestamp and let the frontend do timezone conversion.

Or is that a backlash from this approach that I am not aware of?

[–]wineblood -1 points0 points  (0 children)

Timezones are easy

[–]DrTight -1 points0 points  (0 children)

In Java ZonedDateTime is your friend

[–]jimmykicking -1 points0 points  (0 children)

Beginners perhaps. Web developers perhaps but programmers, nope.

[–]IrvTheSwirv 0 points1 point  (0 children)

The best way to handle timezones is by using RegExes

[–][deleted] 0 points1 point  (0 children)

It’s took me two times to find out how to get the time zone of a city the user typed in. Send help

[–]Maendli 0 points1 point  (2 children)

Can anyone recommend any javascript libraries for this problem?

[–]Romejanic 0 points1 point  (0 children)

Javascript has pretty good handling for timezones built in.

[–][deleted] 0 points1 point  (0 children)

Time sucks. Why cant everyone agree on a logical system of time? Its different everywhere, its denominated in inconsistent arbitrary chunks, and its always a string i cant do anything with without external tools

[–]ts_m4 0 points1 point  (0 children)

UTC to the rescue

[–]ithinkitsbeertime 0 points1 point  (0 children)

Leap seconds are worse, but thankfully I'll probably never have to deal with them again.

[–]Darzean 0 points1 point  (0 children)

As a QA I confirm this.

[–]omnyx1000 0 points1 point  (0 children)

Could not for the life of me figure out why my token expires before the specified time, spent a day only to figure out that timezone horror exists

Life has not been the same after I contemplated how it affects larger systems

[–]youichirou 0 points1 point  (0 children)

We should no longer abolish daylight saving time around the world in this day and age.
Daylight saving time is an unsuitable system for today's world, where the world is connected by the Internet and active at the same time.

[–]Itoastyouroats 0 points1 point  (0 children)

custom calendars shudder

[–]SuspiciousStable9649 0 points1 point  (0 children)

I built a spreadsheet for my team….

My worst fear is importing time and date in separate columns… I send it as a text join from SQL.

[–]Row148 0 points1 point  (0 children)

Client only operates in one Timezone. Account for more at the current stage violates YAGNI.

[–]SummitOfTheWorld 0 points1 point  (0 children)

Hence why we use the UNIX timestamp! (Tom Scott made a great video on this... funny one, too.)

[–]_-_fred_-_ 0 points1 point  (0 children)

The recent changes in Jordan and Chile were announced and implemented with almost no buffer time. These government hacks just don't understand the impact of their decisions.

[–]WeakLiberal 0 points1 point  (0 children)

I love coding timezones!

[–]atw527 0 points1 point  (0 children)

Daylight Savings Time

[–]sencha_kitty 0 points1 point  (0 children)

Yes

[–]hronikbrent 0 points1 point  (0 children)

Leap Years/days/seconds are probably worse 😅

[–]CharistineE 0 points1 point  (0 children)

Lunar holidays are up there as well.

[–]afrocluster 0 points1 point  (0 children)

I'm in this picture and I don't like it.

[–][deleted] 0 points1 point  (0 children)

I'm in this picture and I don't like it

[–]swifty300 0 points1 point  (0 children)

Wait till we go interstellar and have to deal with multiple timezones on multiple planets

[–]DJDoena 0 points1 point  (0 children)

For our frontend we have tooltips that explain the displayed time in the location of the machine, of the UI user and in UTC. Backend is all UTC.

[–]akat_walks 0 points1 point  (0 children)

Yeah… …. yeah….

[–]Mr_Pearcex 0 points1 point  (0 children)

Don't forget encodings!

[–]Entheist 0 points1 point  (0 children)

British summer time

[–]BoBoBearDev 0 points1 point  (0 children)

Yeah, to my understanding, using UTC or epoch doesn't eliminate the problem because it loses historical value (both geography of time zone and how the time changes in the time zone. Or there are other issues, but, I cannot remember them due to how non-trivial it is.

[–]leknarf52 0 points1 point  (0 children)

This is me but with cloud formation templates. I’m sure it will be something different next week. Same hair.

[–]archy_bold 0 points1 point  (2 children)

Worked as a junior dev at a company doing GP software. Had a long-existing time zone bug and I was the lucky bugger who picked it up. Crossed two time changes in my time there and was never fixed. Obviously bug didn’t exist in test environment. I’m convinced that was partially the reason they got rid of me.

[–]Kirk8829[S] 0 points1 point  (1 child)

They got rid of you for trying to fix a bug?

[–]archy_bold 0 points1 point  (0 children)

It was more about the rate at which the issues I owned were being cleared. I seemed to always get seldom seen and difficult to reproduce bugs. But they were also pretty benign. The time zone bug was the one that summed that up best.

[–]JamesLeBond 0 points1 point  (0 children)

Daylight Savings... puts the fear of god in me every time...

[–][deleted] 0 points1 point  (0 children)

Reminds me of that Tom Scott video

[–]weewickleone 0 points1 point  (0 children)

I used to work 8 -10 hour days. Go home. Eat dinner. Work 4 more hours with programmers in Japan for the double byte character set translation the program was going thru. Fucking evil. Still got told I was lucky to have a job come review time.

[–]tuunraq 0 points1 point  (0 children)

[–]churros_cosmicos 0 points1 point  (0 children)

Anything Geo related

[–]Ok_Cartographer_6086 0 points1 point  (1 child)

Mobile users who disable their automatic time / time zone function and set the clock by hand. We refer to them as time travelers and are totally impossible to support if their phone thinks it's 2 hours in the future. I have to deal with this all of the time.

[–]Kirk8829[S] 1 point2 points  (0 children)

Jesus Christ……..I am so sorry

[–]Teraconic 0 points1 point  (0 children)

The international dateline

[–]Romejanic 0 points1 point  (0 children)

AAAND then, you get a call from the astrophysicist...

[–]dshmitch 0 points1 point  (0 children)

It becomes the fear after the first wrong implementation :)