10

By default, the time in AM/PM style is shown, I would like to have the same that ls gives:

2013-01-09 01:12

That is 24 hours and ISO 8601. How can I do this?

I am aware of the following question. Maybe that question was too general to be answered: How do I change to ISO 8601 date format?

I tried the following:

  1. I click on the actual clock-display and I get a calendar. In that calendar I read "Time & Date Settings.." - so I click on it: No effect. No nothing.

  2. I right-click on the clock-display but I get the same calendar like when left-clicking on it.

false
  • 1,852
  • If you're not locked into Unity, XFCE can do this easily. You can set a custom time format. Mine looks like this: %a, %Y-%b-%d, %I:%M %p – Aaron Franke Nov 25 '16 at 09:15
  • @wjandrea: Not helpful – false May 04 '17 at 22:17
  • @false How not? – wjandrea May 04 '17 at 22:41
  • @false The accepted answer on "How to change the date format" is very good. It explains how to set a custom format and what formats are available. Doesn't that answer your question? – wjandrea May 04 '17 at 22:42
  • @wjandrea: 1mo, you suggest two different answers. 2do, there is nothing about ISO 8601 in that other question. 3tio, I went through it but failed (don't remember why). This accepted answer here was the first to work. – false May 04 '17 at 22:48
  • @false I'm not saying your question is bad or wrong, just that you can find the same answer on other questions. – wjandrea May 05 '17 at 00:14
  • @wjandrea: No, I can't, because of 2do and 3tio. Please read my responses. also, you did not respond to 1mo. – false May 05 '17 at 09:05
  • @wjandrea: Thank you for recommending me to do "a bit of research"... – false May 05 '17 at 14:16

1 Answers1

11

There's no easy way to do it in the GUI. One can either use dconf-editor (which is GUI-ish), and edit two keys in /com/canonical/indicator/datetime (time-format to custom, and custom-time-format to the desired strftime directives, in your case %F %R (or, equivalently, %Y-%m-%d %H:%M)), or do it directly from the terminal with the following two commands (which, just to be clear, change the same keys):

dconf write /com/canonical/indicator/datetime/time-format "'custom'"
dconf write /com/canonical/indicator/datetime/custom-time-format "'%F %R'"

Note that the doubled quotes are necessary due to dconf's idiosyncracies. (For clarity, I'm referring to the nesting of single quotes (') inside double quotes (").) Note also that to include seconds, one can replace %R with %T.

I do not recall which release started including the dconf tools by default, so if they are unavailable, simply install the dconf-tools package and proceed.

Update 2016-05-17: While the above should still work, as a matter of principle it's probably better to access the dconf database via gsettings set than dconf write -- same database, but a tool more intended for end-users. The corresponding GUI-ish tool remains dconf-editor.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Darael
  • 450
  • I see com.canonical.indicator.datetime in the dconf-editor, but there are no values to set. dconf also had no effect. I tried logging out. Maybe I have to place these lines somewhere? Prior to starting X ? – false Jan 09 '13 at 03:07
  • Hmm, that's odd. They show up for me, and the dconf commands take effect immediately, too. Which release art using? – Darael Jan 09 '13 at 18:25
  • It could be 11.10 related. I currently upgrade to 12.04. Will come back. – false Jan 09 '13 at 18:27
  • Ah. I seem to recall there was some slightly odd interaction between gconf and dconf in Oneiric, although I could be wrong. The methods I suggested work for me in both Precise and Quantal, though I haven't an Oneiric machine to hand with which to test. – Darael Jan 09 '13 at 18:30
  • Doesn't work in 13.04 – kaleissin May 08 '13 at 08:06
  • @kaleissin WFM in 13.04 (just tested on a clean install). Try doing it manually in the dconf-editor, which now appears to be installed by default. – Darael May 09 '13 at 21:02
  • 1
    Verified to work in 14.04 - I'd love to have "%F, %R" (above) added as an option in the GUI. – Hannu Aug 05 '14 at 10:49
  • Here someone does it with gsettings. – Joschua May 21 '16 at 07:59