Scroll Down to See All
abortabsacosasctimeasctime_rasinassertatanatan2atexitatofatoiatolbsearchbtowccalloccatclosecatgetscatopenceilclearerrclockcoscoshctimectime_rdifftimediverferfcexitexpfabsfclosefdopenfeofferrorfflushfgetcfgetposfgetsfgetwcfgetwsfopenfprintffputcfputwsfreadfreefreopenfrexpfscanffseekfsetposftellfwidefwprintffwritefwscanfgetcgetchargetenvgetwcgetwchargmtimegmtime_rhypotisalnumisalphaisasciiisblankiscntrlisdigitisgraphislowerisprintispunctisspaceisupperiswalnumiswalphaiswblankiswcntrliswctypeiswdigitiswgraphiswloweriswprintiswpunctiswspaceiswupperiswxdigitisxdigitj0j1jnlabsldexpldivlocaleconvlocaltimelocaltime_rloglog10longjmpmallocmblenmbrlenmbrtowcmbsinitmbsrtowcsmbstowcsmbtowcmemchrmemcmpmemcpymemmovememsetmktimemodfnextafternextafterlnexttowardnexttowardlnl_langinfoperrorpowprintfputcputcharputenvputsputwcputwcharqsortquantexpd32quantexpd64quantexpd128quantized32quantized64quantized128samequantumd32raiserandrand_rreallocregcompregerrorregexecregfreeremoverenamerewindscanfsetbufsetjmpsetlocalesetvbufsignalsinsinhsnprintfsprintfsqrtsrandsscanfstrcasecmpstrcatstrchrstrcmpstrcollstrcpystrcspnstrerrorstrfmonstrftimestrlenstrncasecmpstrncatstrncmpstrncpystrpbrkstrrchrstrspnstrstrstrtodstrtod32strtod64strtod128strtofstrtokstrtok_rstrtolstrtoldstrtoulstrxfrmswprintfswscanfsystemtantanhtimetime64tmpfiletmpnamtoasciitolowertouppertowctranstowlowertowupperungetcungetwcva_argva_copyva_endva_startvfprintfvfscanfvfwprintfvfwscanfvprintfvscanfvsprintfvsnprintfvsscanfvswprintfvswscanfvwprintfvwscanfwcrtombwcscatwcschrwcscmpwcscollwcscpywcscpywcsftimewcslenwcsncatwcsncmpwcsncpywcspbrkwcsptimewcsrchrwcsrtombswcsspnwcsstrwcstodwcstod32wcstod64wcstod128wcstofwcstokwcstolwcstoldwcstombswcstoulwcsxfrmwctobwctombwctranswctypewcwidthwmemchrwmemcmpwmemcpywmemmovewmemsetwprintfwscanfy0y1yn



Function Details : strptime

char *strptime(const char * str,const char * format,struct tm * tm) ;

Return Type : char *

String pointer (array of characters)
Read about return values of strptime function .

1st Parameter Type : const char *

Pointer to read-only string

1st Parameter

Pointer to the null-terminated input string containing the date and time to be parsed.

2nd Parameter Type : const char *

Pointer to read-only string

2nd Parameter

A null-terminated format string specifying the expected structure of the date and time in `str`, using specifiers like `%Y`, `%m`, or `%d`.

3rd Parameter Type : struct tm *

A pointer to a `struct tm`, which represents a broken-down calendar time. The structure contains fields such as year, month, day, hour, minute, and second for representing human-readable time.

3rd Parameter

Pointer to a `struct tm` where the parsed date and time values will be stored.

Read more about parameters of strptime in parameters section
The strptimefunction in C language Parses a time/date string according to the format string and stores the result in a tm structure.
The strptime function converts the character string pointed to by buf to values which are stored in the tm structure pointed to by tm, using the format specified by format. It is the converse function to strftime. The format string consists of zero or more conversion specifications and ordinary characters.
The strptimefunction takes 3 parameters:
  • const char * `str`: Pointer to the null-terminated input string containing the date and time to be parsed.
  • const char * `format`: A null-terminated format string specifying the expected structure of the date and time in `str`, using specifiers like `%Y`, `%m`, or `%d`.
  • struct tm * `tm`: Pointer to a `struct tm` where the parsed date and time values will be stored.
Parses the input string `str` according to the `format` string and stores the extracted date and time values in the `tm` structure. Returns a pointer to the first character in `str` not processed, or `NULL` if the input string does not match the format.
The strptime function return value :
  • Returns a pointer to the first character not processed in this function call
  • If the entire string is consumed, the return value points to the null byte at the end of the string
  • If strptime() fails to match all of the format string, NULL is returned

Output

This example demonstrates basic usage of strptime to parse a date and time string into a tm structure.