I chose a simpler way: I changed the display language from:

to:

Here’s a graph with display language set to English. Time is in 12-hour format.

Here’s the same graph with display language set to English (GB). Time is in 24-hour format.

Click on your user account icon (last icon in Home Assistant’s main menu) and Language will appear at the top of the page.