diff --git a/esphome/core/time.cpp b/esphome/core/time.cpp index 46e38fb3b64..b6fc9b90ad9 100644 --- a/esphome/core/time.cpp +++ b/esphome/core/time.cpp @@ -24,7 +24,7 @@ size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) { // Quick scan: does format contain %Z or %z (but not %%Z/%%z)? bool needs_subst = false; for (const char *p = format; *p; p++) { - if (*p == '%') { + if (*p == '%' && *(p + 1)) { p++; if (*p == '%') continue; // %% is a literal %, skip