Now gives back incorrect time on a Linux machine lazarus / 21-General ---------------------------------------------------------------------- jollytall · 2024-10-28 06:45 I am in the Central Europe time zone, i.e. normally, most of the year, 6 hours ahead of the East Coast US timezone. That is an ideal "distance" for me (simply because the Futures Exchange changes active day at 6PM New York Time, 5PM Chicago Time) and so in my timezone, that is actually just the new day, so my date value is perfect. Now, Europe changed to winter time, but the US stayed in summer for a week. While I used Windows, I had a perfect trick for that. I changed my computer's timezone to Eastern Europe winter time, i.e. GMT+2 and that maintains the distance to New York to be 6 hours away. Now I did the same thing on my Linux set-up, and found out that Now somehow still gives back the CET time. I tried to debug and found that the difference is already there in GetLocalTime as shown in the below example. What else should I change, to get the same time Linux shows me. Everything I checked on the PC is showing EET, not CET. See the program and its output with the linux time on the output screenshot. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  SystemTime: TSystemTime;begin  GetLocalTime(SystemTime);  Writeln('Now=', DateTimeToStr(Now), ' Hour=', SystemTime.Hour);end. ---------------------------------------------------------------------- TRon · 2024-10-28 06:57 I am not sure if I understood the issue correctly but GetLocalTimeOffset describes the calculation for UTC and localtime. ---------------------------------------------------------------------- jollytall · 2024-10-28 07:25 GetLocalTimeOffset gives also back -60, what is the difference between UTC and CET, while my system is now configured to be in EET. I also looked inot GetLocalTimeOffset but it uses TZseconds, and I do not know where that variable is set and how. If you see the printscreen I attached, you see that my linux then thought it was 8:42 (also the timestamp on the Screenshot shows this as does any other program), only Pascal shows 7:42. I cannot figure out where it gets the timezone information. It surely gets it from somewhere and that is the value I had on the PC till yesterday. ---------------------------------------------------------------------- TRon · 2024-10-28 07:39 It retrieves the UTC and UTC offset form your system. That is why you should not have to meddle with changing the timezone manually. usually In your linux config you set the timezone in which you live and if it needs to take daylight saving time into consideration. Additionally the local setup is able to verify if your BIOS clock is using UTC time or not. If that is configured correctly then you should not have to do anything manually. I fail to grasp why you would change your timezone in order to maintain a time difference. Is it software related ? because in that case you should not work with local times rather with UTC times. ---------------------------------------------------------------------- jollytall · 2024-10-28 08:33 Ron, That is actually besides the point why I do it (I send you a detailed PM, it is not a secret but do not want to spam the forum). Just imagine that I moved from Central Europe to Eastern Europe. When arrived, switched on my PC and in the Linux setting (not playing at all with Pascal timezones and offsets and alike) simply changed the timezone to Eastern Europe. My PC nicely shows the time in the new timezone as you can see it on the top of the screenshot I attached. Calling the Pascal time functions (regardless if Now, or other) it still gives me back the Central Europe time. I simply cannot imagine where it gets that figure from, but as you see on the Screenshot, that is what I get. This is what I try to figure out, but no success. Maybe someone in Central Europe and on Linux (Debian) could try to do the same, i.e. change the timezone to Eastern Europe and run my little program below that would help to see the problem. I repeated it on another PC and got the same error. ---------------------------------------------------------------------- TRon · 2024-10-28 08:43 Quote from: jollytall on October 28, 2024, 09:33:06 amMaybe someone in Central Europe and on Linux (Debian) could try to do the same, i.e. change the timezone to Eastern Europe and run my little program below that would help to see the problem. I repeated it on another PC and got the same error. I can do that for you but not right now (I actually can't change the time on this machine, as it will cause mayhem  ). I can do that tomorrow on a test-bench. Perhaps someone else is able to do that quicker for you. fwiw also not able to read your PM right now but will do so asap. ---------------------------------------------------------------------- alpine · 2024-10-28 09:16 @jollytall Can you check this: https://forum.lazarus.freepascal.org/index.php/top ic,67077.msg515444.html#msg515444 Not exactly the same problem but related to Debian and the timezone ---------------------------------------------------------------------- jollytall · 2024-10-28 12:23 @alpine Thank you. This was indeed the solution. Although I changed the timezone in Debian GUI Settings, and Linux showed it correctly, Pascal did pick it up apparently from a deeper layer. I needed to do Code: [Select]sudo dpkg-reconfigure tzdataand since then it works. I need to read more about it, but it seems that Settings as a user only changes the user's timezone and the system timezone remains unchanged (logically, because to change it one needs to be root). Pascal (and since I also found another software working like this) apparently uses the machine's system timezone and not the user timezone. It is good to know and I am happy it works. That is a different question, what is more correct, to use the machine's timezone or the user's timezone? If one asked me in advance, I would probably say it shall be the user's timezone, as he does not need to be aware that there is a machine timezone, and maybe also other users who all want to see their own timezones. But this is not really important if we know what and why the system does.