diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index 6214398f09e0..78cef6bf839e 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -291,7 +291,7 @@ label:
 			if (c == 'H' || c == 'k') {
 				if (i > 23)
 					return (NULL);
-			} else if (i > 12)
+			} else if (i == 0 || i > 12)
 				return (NULL);
 
 			tm->tm_hour = i;