It seems like strftime() unexpectedly modifies errno, which is always set to EINVAL when it returns. Looks like it's not related to any specific format. Here's an example: #include #include #include #include int main(int argc, char *argv[]) { time_t now = time(NULL); struct tm *tm = localtime(&now); char buf[100]; errno = 0; size_t len = strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S.", tm); printf("len=%zu\n", len); printf("buf=%s\n", buf); printf("errno=%d\n", errno); }