wassy92x / lovelace-digital-clock

A custom digital clock card for Home Assistant
MIT License
88 stars 13 forks source link

24H format? #43

Open maxwolfen opened 2 weeks ago

maxwolfen commented 2 weeks ago

Sorry if i ask a noob question. But is it posible to change the time to 24H format rather than AM/PM?

Thanks in advance :)

//Max

mennovanhout commented 2 weeks ago

Heya, I had the same question.

I dove inside the source code here at Github and found the fix:

- type: 'custom:digital-clock'
  dateFormat:
    weekday: 'long'
    day: '2-digit'
    month: 'long'
  timeFormat: 'HH:mm'

Instead of:

type: 'custom:digital-clock'
dateFormat:
  weekday: 'long'
  day: '2-digit'
  month: 'short'
timeFormat:
  hour: '2-digit'
  minute: '2-digit'

I found out that the source code checks if the timeFormat is a string if so he will use that format, if it's an object he will always use 12 hour with the corresponding config. My top comment should fix it :D

maxwolfen commented 2 weeks ago

Ah, that worked great 👍 thanks alot! 😊