Share via


_strtime, _wstrtime

Copy the time to a buffer.

char*_strtime(char*timestr);

wchar_t*_wstrtime(wchar_t*timestr);

Routine Required Header Compatibility
_strtime <time.h> Win 95, Win NT
_wstrtime <time.h> or <wchar.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

Each of these functions returns a pointer to the resulting character string timestr.

Parameter

timestr

Time string

Remarks

The _strtime function copies the current local time into the buffer pointed to by timestr. The time is formatted as hh:mm:ss where hh is two digits representing the hour in 24-hour notation, mm is two digits representing the minutes past the hour, and ss is two digits representing seconds. For example, the string 18:23:44 represents 23 minutes and 44 seconds past 6 P.M. The buffer must be at least 9 bytes long.

_wstrtime is a wide-character version of _strtime; the argument and return value of _wstrtime are wide-character strings. These functions behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tstrtime _strtime _strtime _wstrtime

Example

/* STRTIME.C */

#include <time.h>
#include <stdio.h>

void main( void )
{
   char dbuffer [9];
   char tbuffer [9];
   _strdate( dbuffer );
   printf( "The current date is %s \n", dbuffer );
   _strtime( tbuffer );
   printf( "The current time is %s \n", tbuffer );
}

Output

The current date is 03/23/93
The current time is 13:40:40

Time Management Routines

See Also   asctime, ctime, gmtime, localtime, mktime, time, _tzset