4 ms·
They are UTC - the actual time on the system is measured in seconds since midnight Jan 1 1970 (https://en.wikipedia.org/wiki/Unix_time https://en.wikipedia.org/
by limaoscarjuliet 4y ago
They are UTC - the actual time on the system is measured in seconds since midnight Jan 1 1970 (https://en.wikipedia.org/wiki/Unix_time https://en.wikipedia.org/wiki/Unix_time). This time is then converted to local time per the OS timezone setting. A lot of apps (e.g. databases) will also have their own time zone conversions based on context (e.g. per database connection settings).
As far as practical use of UTC vs local time: I am a developer that happens to work with customers directly. It is difficult enough to get customer to provide timestamps for issues they report in local time, I cannot imagine they would be able to convert to UTC.
Love the local time!
- anonymousiam 4y agoBeat me by five minutes. 100% agree.
- j45 4y agoLocal time is a benefit for users. As much as UTC might be beneficial for sysadmins, and technical teams. The only question is, is the implementation user focused or developer prioritized
- IgorPartola 4y ago> This time is then converted to local time per the OS timezone setting. What exactly do you mean by this? As in, what part of your software stack is doing this. IIRC if you set your OS to be in UTC then anything at the OS level will only speak UTC. Databases and your own software will do what they are told to do but systemd etc. will all speak UTC only. Even running date in the shell should give you a UTC timestamp.
- viraptor 4y agoYour system time is totally different from what userspace cares about. Go ahead, run "TZ=UTC date" (or a different timezone if you're using UTC already). I'm not even sure what you mean by the OS speaking a certain timezone. Basic "time()" will return seconds from the epoch UTC regardless of your system timezone. Things that care about timezones will use relevant conversions.
- cyberpunk 4y agoI’ve seen junior sysadmins and developers repeating this for years also. Don’t know where it comes from. Apart from this issue, I’ve never once see an error due to the tz presentation settings on a server, and I have spent 20 years running many thousands of servers at a time. shrug. Let them have to adjust in grafana/kibana if it helps them sleep I guess..
- IgorPartola 4y agoOf course userspace may convert from what time() returns by spec to any given timezone. But it only does so if you instruct it like you did with TZ= or if it is programmed to do so somehow. I have not delved into systemd’s code but I can’t imagine it arbitrarily converts anything away from UTC time if /etc/localtime is set to UTC.
- viraptor 4y agoTZ doesn't do anything magic. It just tells libc you want your local timezone to be something different than the default. It affects output formatting in a way that the app mostly doesn't need to deal with if it only works with one timezone. I'm not even sure what claim you're making now, but the original msg is just wrong. If an app uses libc, it uses TZ setting - regardless if it's systemd or date or something else. > but I can’t imagine it arbitrarily converts anything away from UTC time if /etc/localtime is set to UTC. It really depends on which part of systemd you mean. There's lots of code in there and quite a few bits deal with timezones explicitly. (Since it sets it for users to begin with) But for basic display it sure uses TZ and localtime as set by the user - and it can be different than the system default. https://github.com/systemd/systemd/blob/cccc14c5a88f000931c67eaf3d776825aa2607f7/src/shared/logs-show.c#L417 https://github.com/systemd/systemd/blob/cccc14c5a88f000931c6...
- IgorPartola 4y agoYou and I are saying the same thing in different ways, except the part about systemd. I didn’t realize it did anything with timezones because I keep thinking of it as just modern initd but I guess it goes beyond that. I didn’t realize that if you remove all mention of local timezones from /etc/ that a user could still break systemd by setting their own TZ.
- 8organicbits 4y agoMy challenge has been getting the user to mention their timezone when providing a local time. I can usually guess within a couple of hours, and then find logs that confirm it.
- kodah 4y agoThe OS tracks time in epoch but your application doesn't. Bugs like this happen because a library that does time conversion for your application has a bug or your application is time sensitive but doesn't know how to handle time travel.