strptime(3) Library Functions Manual strptime(3) strptime - tm LIBRARY Standard C library (libc, -lc) #define _XOPEN_SOURCE /* See feature_test_macros(7) */ #include char *strptime(const char *restrict s, const char *restrict format, struct tm *restrict tm); strptime() , strftime(3): , s, tm ( , broken-down time) , format. The broken-down time structure tm is described in tm(3type). format , , scanf(3). % , . format . , . () - . strptime() . (, ) . , . . . (, ), . . %% %. %a %A , . %b, %B %h , . %c , . %C The century number (0-99). %d %e The day of month (1-31). %D Equivalent to %m/%d/%y. (This is the American style date, very confusing to non-Americans, especially since %d/%m/%y is widely used in Europe. The ISO 8601 standard format is %Y-%m-%d.) %H The hour (0-23). %I The hour on a 12-hour clock (1-12). %j The day number in the year (1-366). %m The month number (1-12). %M The minute (0-59). %n . %p AM PM (: ). %r 12- ( AM PM ). POSIX %I:%M:%S %p. t_fmt_ampm LC_TIME , . %R %H:%M. %S The second (0-60; 60 may occur for leap seconds; earlier also 61 was allowed). %t . %T %H:%M:%S. %U The week number with Sunday the first day of the week (0-53). The first Sunday of January is the first day of week 1. %w The ordinal number of the day of the week (0-6), with Sunday = 0. %W The week number with Monday the first day of the week (0-53). The first Monday of January is the first day of week 1. %x . %X . %y The year within century (0-99). When a century is not otherwise specified, values in the range 69-99 refer to years in the twentieth century (1969-1999); values in the range 00-68 refer to years in the twenty-first century (2000-2068). %Y , (, 1991). E O, , . , . E , - : %Ec . %EC . %Ex . %EX . %Ey %EC . %EY . O , : %Od %Oe ; , . %OH (0-24) . %OI (1-12) . %Om . %OM . %OS . %OU ( -- ) . %Ow The ordinal number of the day of the week (Sunday=0), using the locale's alternative numeric symbols. %OW ( -- ) . %Oy ( %C) . , . , , , . , , null. strptime() , NULL. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |strptime() | | MT-Safe env locale | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2008. POSIX.1-2001, SUSv2. , tm, . , tm . UNIX. glibc , , tm_wday tm_yday, : , . The 'y' (year in century) specification is taken to specify a year in the range 1950-2049 by glibc 2.0. It is taken to be a year in 1969-2068 since glibc 2.1. glibc glibc strptime() strftime(3) ( , , tm ). : %F Equivalent to %Y-%m-%d, the ISO 8601 date format. %g The year corresponding to the ISO week number, but without the century (0-99). %G , ISO (, 1991). %u The day of the week as a decimal number (1-7, where Monday = 1). %V The ISO 8601:1988 week number as a decimal number (1-53). If the week (starting on Monday) containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. %z An RFC-822/ISO 8601 standard timezone specification. %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) Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 28 2024 . strptime(3)