How to change time display to 12h time format in Ubuntu

There are several ways:

  1. From GUI (Settings):

    Open Settings >Details> Date & Time. Then pick either 24 hrs or am/pm

  2. From GUI (using dconf-editor)

    Open dconf Editor (not installed by default, run

    sudo apt install dconf-editor
    

    to install), and browse to org > gnome > desktop > interface > clock-format, and change the format to '12h'

    enter image description here

  3. From command line:

    Run the command:

    gsettings set org.gnome.desktop.interface clock-format '12h'   
    

    To revert:

    gsettings set org.gnome.desktop.interface clock-format '24h'
    

To run the following commands, first install the dconf-editor package:

sudo apt install dconf-editor

Then run this command, to switch to 12-hour mode:

gsettings set org.gnome.desktop.interface clock-format '12h'   

If you ever want to revert to 24-hour mode, you can do so by running:

gsettings set org.gnome.desktop.interface clock-format '24h'