You are not logged in.

#1 2013-07-16 15:58:35

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

[SOLVED] UTC Time Displaying Localtime

I am trying to get Conky to display the correct UTC time on my desktop, but the localtime is being displayed instead. In light of this issue, I concluded that the hardware clock must be set to use localtime, rather than UTC, and or that the system clock is not syncing correctly with the hardware clock on boot up.

So, I tried issuing the command

 timedatectl set-local-rtc 0 

to set the system time to use UTC as indicated in this ArchWiki page. However, even after rebooting, Conky still displays the localtime rather than the UTC time.

Issuing the command

 timedatectl status 

results in the output

 
Local time: Tue 2013-07-16 07:27:07 EDT
Universal time: Tue 2013-07-16 11:27:07 UTC
RTC time: Tue 2013-07-16 11:27:07
Timezone: America/New_York (EDT, -0400)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
                           Sun 2013-03-10 01:59:59 EST
                           Sun 2013-03-10 03:00:00 EDT
Next DST change: DST ends (the clock jumps one hour backwards) at
                            Sun 2013-11-03 01:59:59 EDT
                            Sun 2013-11-03 01:00:00 EST

After having tried the above command without success, I then entered into the system BIOS on boot, and inspected the hardware clock time, which is correctly set to the UTC time.

So, after booting again into Arch Linux, I tried using the

 hwclock 

command to troubleshoot the problem.

Issuing the command

 hwclock --debug 

yields

hwclock from util-linux 2.23.1
Using /dev interface to clock.
Last drift adjustment done at 1373971186 seconds after 1969
Last calibration done at 1373971186 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2013/07/16 11:19:10
Hw clock time : 2013/07/16 11:19:10 = 1373973550 seconds since 1969
Tue 16 Jul 2013 07:19:10 AM EDT  -0.985669 seconds

According to the output above, the

 Hardware clock is on UTC time 

, so I am not sure why the system clock is not syncing properly with the hardware clock on boot up.

Issuing the command

 hwclock -r 

yields

 Tue 16 Jul 2013 07:37:51 AM EDT  -0.797938 seconds 

which displays localtime, instead of UTC.

In addition, I find it somewhat confusing that

 hwclock --localtime 

yields

 Tue 16 Jul 2013 11:39:23 AM EDT  -0.079090 seconds 

which appears to be the UTC time, and issuing

 hwclock --utc 

yields

 Tue 16 Jul 2013 07:40:17 AM EDT  -0.485343 seconds 

which appears to be the localtime.

I also tried using the command

 hwclock --systohc 

according to this question on serverfault.com, with no success.

The output of the

 date 

command is

 Tue Jul 16 07:46:03 EDT 2013 

, which appears to be the localtime, rather than the UTC time.

I noted that in the ouput of

 timedatectl status 

it says

 
NTP enabled: n/a
NTP synchronized: no

which I believe may be contributing to the problem, but I am somewhat unclear as to whether or not NTP is necessary for the system time to be correctly synced with the hardware clock and the UTC time.

Also, I am using the Conky Metro Clock Conky configuration for my .conkyrc file.

Any help would be greatly appreciated.
Thank you.

EDIT:
For clarification, I did not actually actual want to display the UTC time with Conky, but rather the localtime. I accidentally concluded that I wanted to display the UTC time because my hardware clock was synced to my localtime, rather than the actual UTC time. Therefore, this caused the UTC time to be synced with the localtime, and furthermore, the localtime to be 4 hours behind the correct localtime in my timezone (UTC-4hrs).

Last edited by kevin.gurney (2013-07-16 22:52:15)

Offline

#2 2013-07-16 16:44:49

Fixxer
Member
From: Poland
Registered: 2011-08-29
Posts: 220

Re: [SOLVED] UTC Time Displaying Localtime

Show:

cat /etc/adjtime

Offline

#3 2013-07-16 16:45:36

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] UTC Time Displaying Localtime

I don't see anything at all incorrect in any of that output. Your hardware clock is set to UTC, and your timezone is set to UTC-4, so your localtime is UTC-4 hours. "date" always returns local time. "hwclock -r" returns local time (check the "hwclock" man page)

-r, --show
              Read  the Hardware Clock and print the time on standard output.  The time shown is always in local time, even if you keep your Hardware Clock
              in Coordinated Universal Time.  See the --utc option.  Showing the Hardware Clock time is the default when no function is specified.

Read the wiki page you linked again. It says that the timedatectl command you used sets the hardware clock (not the system clock) to UTC. Your hardware clock is already using UTC, so this command had no effect.

If you want your local time to be UTC, you need to set your time zone to UTC, instead of UTC-4.

sudo timedatectl set-timezone UTC

Last edited by 2ManyDogs (2013-07-16 16:59:38)

Offline

#4 2013-07-16 17:08:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] UTC Time Displaying Localtime

I can't add much beyond what 2MD said, except to agree.  Everything looks like it's working just right.  You set a time zone, so it shows you time in that time zone.

The one relevant bit is the one you didn't post: your conky config.  Do you have something in particular to get conky to show UTC?  If you use any of the 'standard' clocks for conky, they show system (aka local) time.

You could change your timezone to UTC, or if this is just for conky, adjust your conky config appropriately.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2013-07-16 19:39:54

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

Thanks, I will try setting my timezone to UTC. I apologize for not directly posting the Conky Configuration file, here it is

double_buffer yes
no_buffers yes

text_buffer_size 2048

# Window specifications
own_window yes
own_window_class conky
own_window_transparent yes
own_window_hints undecorate,below,sticky,skip_taskbar,skip_pager

border_inner_margin 0
border_outer_margin 0

alignment bl
gap_x 100
gap_y 100

# Graphics settings
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

# Text settings
use_xft yes
xftalpha 0
text_buffer_size 2048

uppercase no

default_color FFFFFF

TEXT
${voffset 10}${font Open Sans Light:size=50}${time %A}${font}${voffset -10}
${voffset 10}${font Open Sans Light:size=50}${time %B} ${time %e}${font}${voffset -10}
${voffset 10}${font Open Sans Light:size=100}${time %I:%M %p}${font}${voffset -10}

Last edited by kevin.gurney (2013-07-16 19:40:20)

Offline

#6 2013-07-16 21:12:14

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

Thank you Trilby, 2ManyDogs, and Fixxer for your help. I changed my timezone from UTC-4 to UTC using

 sudo timedatectl set-timezone UTC 

and now my localtime is being displayed as UTC time with Conky. I apologize for the confusion.

Although this solved the problem, I am slightly unclear as to why my previous localtime, which was set to my appropriate timezone, is not showing the time that would be displayed on an "ordinary" clock. Is the localtime simply the time relative to UTC with the offset associated with a particular time zone (in this case, 4 hours)? If you don't mind, I would appreciate any clarification that you can provide on the distinction between localtime and UTC.

Last edited by kevin.gurney (2013-07-16 21:15:10)

Offline

#7 2013-07-16 21:33:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] UTC Time Displaying Localtime

Can you clarify what you mean?

If your timezone is UTC-4hrs, then that is what should be shown on an "ordinary" clock, right?

When it is UTC midnight, it is 8pm at your house.  Your house clocks say 8pm, right?  Conky, in your original (and typical) configuration would say 8pm.  But you want it to actually show you midnight.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2013-07-16 22:00:45

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

Well, actually an "ordinary" clock shows the time that is equivalent to UTC time, which is why I am somewhat confused about the distinction between localtime and UTC. The localtime appears to be behind 4 hours from the time that an "ordinary clock" in my timezone shows. Perhaps, this page which shows the localtime can clarify. According to my system clock, prior to setting my timezone to UTC, the localtime was 4 hours behind the time shown on that page, whereas an "ordinary" clock in my timezone would show the time displayed on that page next to the section titled Current Time. Again, I apologize for the confusion.

Last edited by kevin.gurney (2013-07-16 22:05:35)

Offline

#9 2013-07-16 22:06:34

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] UTC Time Displaying Localtime

"local time" == the time a clock at your house shows

"UTC" == the time a clock in Greenwich England shows

UTC is the same all over the world (that's why it's called Universal Time) but local time varies depending on your time zone.

If your timezone is set to UTC, and "date" shows the actual time at your house (and you do not live in England), your hardware clock is not set to UTC, it is set to the local time.

The situation you describe (time zone set to New York, but "date" shows actual time in new York minus four hours) is exactly what would happen if your hardware clock was set to local time, not UTC.

Show us

hwclock --debug

and this time tell us what is the actual time at your house (the time all your wall clocks show) when you run this command.

Last edited by 2ManyDogs (2013-07-16 22:11:15)

Offline

#10 2013-07-16 22:11:53

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

I actually just Googled "UTC time", and it appears that the UTC time displayed by

timedatectl status

is actually 4 hours behind the actual UTC time. This would explain why when my timezone was set to UTC-4hrs that my localtime was actually 4 hours behind the time that an "ordinary" clock shows in my timezone. Is there a way to resync the UTC time, so that the correct localtime will be displayed when my timezone is set appropriately?

Last edited by kevin.gurney (2013-07-16 22:26:41)

Offline

#11 2013-07-16 22:15:13

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

The output of

 hwclock --debug 

is

hwclock from util-linux 2.23.1
Using /dev interface to clock.
Last drift adjustment done at 1373976360 seconds after 1969
Last calibration done at 1373976360 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2013/07/16 18:13:23
Hw clock time : 2013/07/16 18:13:23 = 1373998403 seconds since 1969
Tue 16 Jul 2013 06:13:23 PM UTC  -0.470173 seconds

and the current time shown by a clock at my house is 6:13.

Offline

#12 2013-07-16 22:16:21

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] UTC Time Displaying Localtime

Your hardware clock is set to local time, not UTC. Set your hardware clock to UTC, using

# timedatectl set-time "2012-10-30 18:17:16"

Where the string in quotes is actual UTC time (your local time plus four hours).

If you keep your timezone set to UTC, conky should now show the time in UTC, not local, and so will "date" -- if you change your timezone back to New York, conky and "date" will both show local time (even though your hardware clock is set to UTC!)

(edit) I have to ask -- why do you want conky to show UTC, since you don't really seem to understand what it means? Most people want to see the local time, not the time in England, unless they live there of course). Do you have a specialized application for UTC (such as amateur radio logging, or something similar)?

Last edited by 2ManyDogs (2013-07-16 22:25:01)

Offline

#13 2013-07-16 22:21:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED] UTC Time Displaying Localtime

And if you dual boot with Windows, you'll need to read the wiki page for Time, to see how to prevent Windows from reseting your hardware clock to local time.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#14 2013-07-16 22:30:01

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

2ManyDogs, I don't actually want to display the UTC time. The reason why I originally wanted to display the UTC time was because it appeared to be the correct time because it was actually set to the localtime in my timezone. Therefore, the localtime that was being displayed on my system was actually 4 hours behind the correct time in my timezone relative to this UTC time since my timezone is UTC-4hrs. I apologize for the misunderstanding, although I do understand the difference between UTC and my localtime, it it simply a matter of the UTC time being incorrect on my system, and, therefore, the localtime, as well.

Offline

#15 2013-07-16 22:32:34

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

Ok, so, like 2MayDogs suggested, I switched my hardware clock from using localtime to UTC time by issuing the command

timedatectl set-time "<current UTC time>"

and then changed my timezone back to UTC-4hrs, and now Conky is correctly displaying the localtime in my timezone. Thank you all for your help.

Last edited by kevin.gurney (2013-07-16 22:36:02)

Offline

#16 2013-07-16 22:34:20

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] UTC Time Displaying Localtime

kevin.gurney wrote:

2ManyDogs, I don't actually want to display the UTC time. The reason why I originally wanted to display the UTC time was because it appeared to be the correct time because it was actually set to the localtime in my timezone. Therefore, the localtime that was being displayed on my system was actually 4 hours behind the correct time in my timezone relative to this UTC time since my timezone is UTC-4hrs. I apologize for the misunderstanding, although I do understand the difference between UTC and my localtime, it it simply a matter of the UTC time being incorrect on my system, and, therefore, the localtime, as well.

Ah. We could have helped you much more quickly if we understood what the real problem was. Oh well, at least you have it the way you want it now.

This is what confused me:

kevin.gurney wrote:

I am trying to get Conky to display the correct UTC time on my desktop

With your last explanation, I understand what you were actually asking for.

Last edited by 2ManyDogs (2013-07-16 22:36:26)

Offline

#17 2013-07-16 22:41:54

kevin.gurney
Member
Registered: 2013-07-16
Posts: 14

Re: [SOLVED] UTC Time Displaying Localtime

I apologize for that. My reason for stating that was simply due to the fact that the UTC time was displaying the time in my timezone (localtime), so therefore, I prematurely jumped to the conclusion that the UTC time was the time that I wanted displayed. However, what I really wanted to be displayed was the localtime, which seemed incorrect because it was 4 hours behind the actual localtime in my timezone (UTC-4hrs) since the UTC time was incorrectly synced with the localtime, rather than the actual UTC time.

I have made an edit to my original post for clarification, and modified the post title, as well, for clarity.

Thank you again, 2ManyDogs! I really appreciate your help!

Last edited by kevin.gurney (2013-07-16 22:53:19)

Offline

Board footer

Powered by FluxBB