This documentation is archived and is not being maintained.

_strtime, _wstrtime

Copy the time to a buffer.

char *_strtime(
   char *timestr 
wchar_t *_wstrtime(
   wchar_t *timestr 


Time string.

Return Value

Returns a pointer to the resulting character string timestr.


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


Routine Required header Compatibility
_strtime <time.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_wstrtime <time.h> or <wchar.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_strtime.c

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

int 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 );

Sample Output

The current date is 02/06/02
The current time is 14:21:44

See Also

Time Management Routines | asctime | ctime | gmtime | localtime | mktime | time | _tzset | Run-Time Routines and .NET Framework Equivalents