Yes, with the help of `strftime` you can use your own time and date formats in the DesktopDigitalClock. The `strftime` function allows you to format the date and time as you wish.Information about strftime on >> ... learn.microsoft.com/ .. strftime-wcsftime-strftime-l-wcsftime-l?view=msvc-170 1. Enabling your own time and date formats:
|
(Image-1) Use your own time and date formats for the desktop clock! |
![]() |

2.) Here are some examples of possible formatting:
- `%H:%M:%S` → 24-hour format (e.g. 14:30:15)
- `%I:%M:%S %p` → 12-hour format with AM/PM (e.g. 02:30:15 PM)
- `%A, %d. %B %Y` → Day of the week, day, month, year (e.g. Monday, February 26, 2024)
- `%d-%m-%Y %H:%M` → Short date format with time (e.g. 26-02-2024 14:30)
By adjusting these formats, you can customize the appearance of the DesktopDigitalClock.
3.) Here are other possible `strftime` formats for the DesktopDigitalClock:
Time formats
- `%H:%M` → 24-hour time without seconds (e.g. 14:30)
- `%I:%M %p` → 12-hour time without seconds (e.g. 02:30 PM)
- `%H:%M:%S.%f` → Time with microseconds (e.g. 14:30:15.123456)
- `%X` → Local time format (depending on system setting)
Date formats
- `%d.%m.%Y` → German standard format (e.g. 26.02.2024)
- `%m/%d/%y` → US format with two-digit year (e.g. 02/26/24)
- `%B %d, %Y` → month spelled out with day and year (e.g. February 26, 2024)
- `%A, %B %d` → day of the week and month with day (e.g. Monday, February 26)
- `%Y-%m-%d` → ISO format (e.g. 2024-02-26)
- `%Y-W%V-%u` → calendar week and day of the week (e.g. 2024-W09-1 for Monday of the 9th calendar week)
Combined formats
- `%A, %d. %B %Y - %H:%M:%S` → Full date with time (e.g. Monday, February 26, 2024 - 14:30:15)
- `%d/%m/%Y %I:%M:%S %p` → European date with 12-hour time (e.g. 26/02/2024 02:30:15 PM)
- `%Y-%m-%d %H:%M:%S` → ISO date with time (e.g. 2024-02-26 14:30:15)
- `Today is %A, the %d. %B %Y, and the time is %H:%M:%S`
→ (e.g. "Today is Monday, February 26, 2024, and the time is 14:30:15")
You can use these formats in the DesktopDigitalClock to display the date and time exactly as you wish. 😊
4.) What should you pay particular attention to with date and time formats!?
When adjusting date and time formats in the DesktopDigitalClock with `strftime`, there are a few important points to consider:
1. Adjust formatting for different languages
- The names of weekdays (`%A`) and months (`%B`) are displayed in the language of the system.
- If the system is set to English, for example, "Monday" appears instead of "Montag".
- For uniform language settings it may be necessary to adjust the language of the system or application.
2. Consider 12- or 24-hour format
- `%H` (24-hour format) → 14:30
- `%I` (12-hour format) with `%p` → 02:30 PM
- In countries like Germany the 24-hour format is more common, while in the USA the 12-hour format with AM/PM is more commonly used.
3. Separator and order of the date
- German format: `%d.%m.%Y` → 02/26/2024
- US format: `%m/%d/%Y` → 02/26/2024
- ISO format (recommended for international use): `%Y-%m-%d` → 2024-02-26
The wrong separator or an unusual order can lead to misunderstandings, especially between US and EU formats!
4. Consideration of leading zeros
- `%d` and `%m` → with leading zero (e.g. 03/05/2024)
- `%-d` and `%-m` (not supported everywhere) → without leading zero (e.g. 3/5/2024)
5. Display calendar week and weekdays correctly
- `%V` outputs the ISO calendar week (e.g. 09 for the 9th week).
- `%u` outputs the weekday as a number (1 = Monday, 7 = Sunday).
- Different countries start the week differently:
- Germany: Monday as the first day
- USA: Sunday as the first day
6. Combine time and date information
- By default, there is no space between date and time information, so it must be inserted manually:
- Incorrect: `%d.%m.%Y%H:%M:%S` → 26.02.202414:30:15
- Correct: `%d.%m.%Y %H:%M:%S` → 26.02.2024 14:30:15
7. Consider daylight saving time and time zones
- `%Z` outputs the time zone as an abbreviation (e.g. CET for Central European Time).
- `%z` outputs the time zone as an offset to UTC time (e.g. +0100 for CET or +0200 for CEST).
- These details may change with daylight saving time and should be taken into account for international applications.
Conclusion
To avoid misunderstandings, you should:
✔ Check the correct language for month and weekday names.
✔ The correct date format depending on
✔ Use the appropriate time format (12h or 24h).
✔ Observe time zones & daylight saving time if relevant.
✔ Set separators & spaces correctly.
This ensures a precise and easy-to-read display in the DesktopDigitalClock. 😊
FAQ 29: Updated on: 27 February 2025 18:55