1

I am used to XFCE in various distributions, but thought I would try Ubuntu with GNOME for a change and to understand why so many people use it.

Frustratingly, I cannot find out how to change the date and time formatting to my preference. This is extremely simple in XFCE, but apparently not so much in Ubuntu with GNOME. In XFCE my time and date settings would be %A %d %B %Y %H:%M:%S (%Z), which would yield Monday 05 February 2024 13:13:43 (GMT). There are very limited options in the settings menu but my preferred formatting is not offered.

Is there a way to load this in the latest version of Ubuntu with GNOME (23.10)? Google searches only seem to offer the limited settings options.

  • Also refer How to Install GNOME Extensions if you need help with that. – rusty Feb 05 '24 at 14:42
  • Thanks for your suggestions. Unfortunately there do not appear to be many time/date adjusters available in Extensions apparently due to my using the “latest” Ubuntu not the LTS. Being autistic I cannot accept “Sun” it has to be Sunday similarly “Feb” and I absolutely cannot stand the ridiculous “am and pm” in this day and age. Hence why I would like to format to my preference not unsuitable or shortened alternatives. – Tippunmon Feb 05 '24 at 20:58
  • @Tippunmon See my second answer at the linked duplicate. In your case just put your format specifiers mentioned in your question (%A %d %B %Y %H:%M:%S (%Z)) inside the dconf command and you should have the time and date format that you desire. – BeastOfCaerbannog Feb 09 '24 at 20:42

1 Answers1

2

I made an extension that is compatible with Gnome Shell 45 on Ubuntu 23.10:

  1. Paste the following into ~/.local/share/gnome-shell/extensions/customDateTimeFormatting_1502527_1004020@askubuntu.com/metadata.json:

    {
        "uuid": "customDateTimeFormatting_1502527_1004020@askubuntu.com",
        "name": "Wall clock custom datetime formatter",
        "description": "Changes the wall clock date and time formatting to your preference",
        "shell-version": [ "45" ],
        "url": "https://askubuntu.com/q/1502527/1004020"
    }
    
  2. Paste the following into ~/.local/share/gnome-shell/extensions/customDateTimeFormatting_1502527_1004020@askubuntu.com/extension.js

    import GLib from 'gi://GLib';
    import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
    import {panel} from 'resource:///org/gnome/shell/ui/main.js';
    

    export default class CustomDateTimeFormattingExtension extends Extension { enable() { const { _clock, _clockDisplay } = panel.statusArea.dateMenu; _clock.force_seconds = true; // Update every minute -> update every second _clock.connectObject('notify::clock', () => { // This runs after the original code, // so we can just overwrite the original text. _clockDisplay.set_text( // Change the string on the new line according to your preferences: GLib.DateTime.new_now_local().format('%A %d %B %Y %H:%M:%S (%Z)') // No semicolon should be placed here ); }, this); }

    disable() {
        const { _clock } = panel.statusArea.dateMenu;
        _clock.disconnectObject(this);
        _clock.force_seconds = false;
    }
    

    }

  3. Relog

  4. Run gnome-extensions enable customDateTimeFormatting_1502527_1004020@askubuntu.com

    new date format preview

It does not have the preferences feature of the Panel Date Format extension (currently stuck on gnome-shell 42 on Ubuntu ≤ 22.04), owing to my goal of simplicity. If you want to change the format, you can just edit the extension.js and relog. My extension should be enough to solve this question. If you need more features, you can either comment, or wait for the Panel Date Format extension to get updated.

muru
  • 197,895
  • 55
  • 485
  • 740
Daniel T
  • 4,594
  • That’s incredibly kind of you and please allow me to express my gratitude. Thank you so much for your kindness and patience. – Tippunmon Feb 09 '24 at 19:17
  • @Tippunmon On AskUbuntu, we usually click the "accept answer" (https://meta.stackexchange.com/a/5235/1373352) button instead of saying "thank you" or editing the title to contain "solved" – Daniel T Feb 09 '24 at 19:20