strptime(3) Library Functions Manual strptime(3) strptime - tm (libc -lc) #define _XOPEN_SOURCE /* feature_test_macros(7) */ #include char *strptime(const char *restrict s, const char *restrict format, struct tm *restrict tm); strptime() strftime(3); s " " tm format. tm tm(3type). format scanf(3). % . format . . strptime() . ( ) . . . . ( ) . . %% %. %a %A . %b %B %h . %c . %C (0-99). %d %e (1-31). %D %m/%d/%y. ( %d/%m/%y . ISO 8601 %Y-%m-%d.) %H (0-23). %I 12 (1-12). %j (1-366). %m (1-12). %M (0-59). %n . %p AM PM. (: .) %r 12 ( AM PM ). POSIX %I:%M:%S %p. t_fmt_ampm LC_TIME . %R %H:%M. %S (0-60; 60 61). %t . %T %H:%M:%S. %U (0-53). 1. %w (0-6) = 0. %W (0-53). 1. %x . %X . %y (0-99). 69-99 (1969-1999) 00-68 (2000-2068). %Y ( 1991). E O . . E : %Ec . %EC () . %Ex . %EX . %Ey %EC ( ) . %EY . O : %Od %Oe . %OH ( 24 ) . %OI ( 12 ) . %Om . %OM . %OS . %OU ( ) . %Ow (=0) . %OW ( ) . %Oy ( %C) . . . . strptime() NULL. attributes(7). +----------------------+------------------------------------+----------------------------------------------------------------------------------------+ | | | | +----------------------+------------------------------------+----------------------------------------------------------------------------------------+ |strptime() | | (MT-Safe) | +----------------------+------------------------------------+----------------------------------------------------------------------------------------+ POSIX.1-2008. POSIX.1-2001, SUSv2. tm . tm . UNIX . glibc tm_wday tm_yday . 'y' ( ) 1950-2049 glibc 2.0. 1969-2068 glibc 2.1. glibc glibc strptime() strftime(3). ( tm.) : %F %Y-%m-%d ISO 8601. %g ISO (0-99). %G ISO. ( 1991.) %u (1-7 = 1). %V ISO 8601:1988 (1-53). ( ) 1 1. 1. %z RFC-822/ISO 8601. %Z . GNU strftime(3) %k %H %l %I %P %p. : %s 1970-01-01 00:00:00 +0000 (UTC). . glibc . strptime() strftime(3). #define _XOPEN_SOURCE #include #include #include #include int main(void) { struct tm tm; char buf[255]; memset(&tm, 0, sizeof(tm)); strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm); strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm); puts(buf); exit(EXIT_SUCCESS); } time(2) getdate(3) scanf(3) setlocale(3) strftime(3) 3 . . : . 6.18 6 2026 strptime(3)