Digital Clock Settings


19 posts
by nounoua » Sat Jan 12, 2013 1:23 am
Hi all,

I've had my Pi for four weeks now, but I haven't been able to properly change the settings of the digital clock in the menu bar/panel. I can open the settings window, but then in the text edit lines to change the settings I get some codes which I don't know what stand for. If I use '%A' I get the date, and '%R' gets me the time in 24 hr format. Is there a way to display both the date, and time in 12-hour format?
Posts: 7
Joined: Sat Dec 29, 2012 5:59 am
by mikef » Mon Jan 21, 2013 4:00 am
Notice in the Digital Clock settings dialog it says: Format codes: man 3 strftime |n for line break

Which means you can find the formatting codes with the man utility. Type: man 3 strftime

This will run the man (manual) utility that display the instructions for the strftime command (format date and time). You can use the same formatting characters in the Clock Format and Tooltip Format input boxes to specify how you want the date and/or time to appear. You can use %n to add a line break to format date/time over more than one line.
Posts: 1
Joined: Mon Jan 21, 2013 2:37 am
by swerve151 » Wed Feb 20, 2013 3:18 am
@Nounoua

%r will give you a 12 hour clock with am/pm indicator
%R will give you a 24 hour clock
%X will give you a 24 hour clock with seconds
%x will give you the date in this format DD/MM/YY
%d will give you the day in number format
%D will give you the date in this format MM/DD/YY
%a will give you the abbreviated day name
%A will give you the full day name
Posts: 1
Joined: Wed Feb 20, 2013 3:08 am
by aberts10 » Sun Jul 27, 2014 3:27 am
i did a 12 hour clock format with this....

%I:%M %p

just set your timezone in raspi with "sudo raspi-config",
then right click the clock and paste it in.
Posts: 15
Joined: Mon Mar 31, 2014 1:57 am
Location: United States
by lgtronik » Sun Nov 15, 2015 7:22 pm
My Digital Clock settings are: %d %h %Y / %X
Posts: 1
Joined: Sun Nov 15, 2015 7:18 pm
by supra » Mon Nov 16, 2015 2:01 am
I set mine %r :)
Posts: 559
Joined: Thu Feb 28, 2013 9:21 am
Location: Ontario, Canada
by IndyPi » Wed Dec 09, 2015 3:51 am
Posts: 1
Joined: Wed Dec 09, 2015 3:49 am
by amnya » Thu May 12, 2016 2:42 pm
I have set mine to:
%a %d.%h.%Y / %I:%M %p

Which translates to:
Thu 12.May.2016 / 05:41 pm
Posts: 1
Joined: Thu May 12, 2016 2:38 pm
by chexbox » Thu May 12, 2016 11:17 pm
On my pi the clock does not count time when the pi is off. It does not fix upon start-up. How do I fix this? :?
Posts: 20
Joined: Thu Apr 28, 2016 11:31 pm
Location: US
by klricks » Fri May 13, 2016 12:16 am
chexbox wrote:On my pi the clock does not count time when the pi is off. It does not fix upon start-up. How do I fix this? :?


The time should be set as soon as the Internet connection is established sometime during the boot process or soon after. If you don't have internet connection then you need a RTC module of some sort with a battery backup.
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click web icon on right side --->
Posts: 4106
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
by Rive » Fri May 13, 2016 1:17 am
mine is "%r" (and if you hoover the mouse over the time it gives date e.g., "Thursday 05/12/2006")
DNPNWO
User avatar
Posts: 586
Joined: Sat Mar 26, 2016 5:21 pm
Location: USA
by chexbox » Fri May 13, 2016 9:05 pm
klricks wrote:
chexbox wrote:On my pi the clock does not count time when the pi is off. It does not fix upon start-up. How do I fix this? :?


The time should be set as soon as the Internet connection is established sometime during the boot process or soon after. If you don't have internet connection then you need a RTC module of some sort with a battery backup.

It still does not work. The date is wrong too. :?:
find me at https://scratch.mit.edu/users/chexbox/
Posts: 20
Joined: Thu Apr 28, 2016 11:31 pm
Location: US
by reltek » Thu Jul 28, 2016 3:41 pm
chexbox wrote:
klricks wrote:
chexbox wrote:On my pi the clock does not count time when the pi is off. It does not fix upon start-up. How do I fix this? :?


The time should be set as soon as the Internet connection is established sometime during the boot process or soon after. If you don't have internet connection then you need a RTC module of some sort with a battery backup.

It still does not work. The date is wrong too. :?:


Raspberry PI is not like your computer tower keeping time even if you shut it down. PI's date and time comes from Your Internet connection and is set at boot-time. That means when you boot up your PI it should already be connected to a NETWORK with Internet Access.

In the event your PI doesn't have Internet Access when it boots up, its time and date doesn't change but starts where it left off when you shut it down. To overcome this shortcoming you need to something like Real-Time-Clock module that you need to connect to your PI's GPIO pins. Then, you need to have a script or a program that will be called at boot time to read the module time and set it to PI's system clock. This doesn't mean date and time will be accurate - even RTC module drifts, which means you need to also update RTC date and time from your PI's System clock once a day or maybe once a week using CRONTAB. It is really helpful to use wiringPI library, if you are going to be doing this.
Posts: 20
Joined: Wed Jan 13, 2016 3:15 pm
by franzsunil » Sun Sep 11, 2016 2:57 pm
Date and time information shown on the panel digital clock area uses the linux strftime format for date and time. Please see http://linux.die.net/man/3/strftime for details.
Posts: 1
Joined: Sun Sep 11, 2016 2:50 pm
by LDighera » Wed Jan 04, 2017 9:32 pm
I'm trying to get the date command to print the date and time formatted like this:
Code: Select all
Wednesday, January 4, 2017 1312 PST

using this command:
Code: Select all
/bin/date --date= '+%_A, %B %-d, %Y %H%M %Z'

however, it fails to provide the current time:
Code: Select all
Wednesday, January 4, 2017 0000 PST

When I ussue the 'date' command without any optional formating, it works correctly:
Code: Select all
Wed  4 Jan 13:15:53 PST 2017

The shell TZ veriable is set:
Code: Select all
echo $TZ PST8PDT

The 'locale' command shows the LC_TIME is set:
Code: Select all
LC_TIME="en_GB.UTF-8"

However, the $LC_TIME shell verable is unset. When I set it as above, it still fails to display the time.

I've read the man page, the info page, and the strftime man page, but am still unable to grasp what I'm doing incorrectly.
Perhaps someone will be good enough to execute this command:
Code: Select all
/bin/date --date= '+%_A, %B %-d, %Y %H%M %Z'

and see if it will print the time on your machine. All clues appreciated.
ADVthanksANCE
There is no expedient to which a man will not resort
to avoid the real labor of thinking.
-- Sir Joshua Reynolds
User avatar
Posts: 39
Joined: Wed Aug 29, 2012 1:04 am
Location: Santa Barbara, California, USA
by DougieLawson » Wed Jan 04, 2017 9:36 pm
Works for me
Code: Select all
pi@viking ~ $ date '+%_A, %B %-d, %Y %H%M %Z'
Wednesday, January 4, 2017 2136 UTC
pi@viking ~ $
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.
User avatar
Posts: 26127
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by LDighera » Wed Jan 04, 2017 9:51 pm
Many thanks, Douglas.

At least now I know it's not a bug in the date command or the format string. But I'm still stumped.
The cause of the issue must be something in my environment.

The only other thing I can think of is that the 'locale' command provides no value for the 'LC_ALL' field. Could that be it? I recall having read something about it needing to be 'LC_ALL=C', but I haven't a clue how to set it.

Thanks again.
There is no expedient to which a man will not resort
to avoid the real labor of thinking.
-- Sir Joshua Reynolds
User avatar
Posts: 39
Joined: Wed Aug 29, 2012 1:04 am
Location: Santa Barbara, California, USA
by rpdom » Wed Jan 04, 2017 9:58 pm
Code: Select all
/bin/date --date= '+%_A, %B %-d, %Y %H%M %Z'

What is that "--date=" doing in there?

With it in I get
Code: Select all
pi@raspberrypi:~ $ /bin/date --date= '+%_A, %B %-d, %Y %H%M %Z'
Wednesday, January 4, 2017 0000 GMT


Without it I get
Code: Select all
pi@raspberrypi:~ $ /bin/date '+%_A, %B %-d, %Y %H%M %Z'
Wednesday, January 4, 2017 2157 GMT
User avatar
Posts: 10315
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by LDighera » Wed Jan 04, 2017 10:17 pm
Thanks for pointing that out, rpdom. It works now.
It's interesting how with the '--date=' it only fails to provide the correct time, and the rest of the output is correct. Interisting.
There is no expedient to which a man will not resort
to avoid the real labor of thinking.
-- Sir Joshua Reynolds
User avatar
Posts: 39
Joined: Wed Aug 29, 2012 1:04 am
Location: Santa Barbara, California, USA