_strtime, _wstrtime
Copy the time to a buffer. More secure versions of these functions are available; see _strtime_s, _wstrtime_s.
char *_strtime(
char *timestr
);
wchar_t *_wstrtime(
wchar_t *timestr
);
template <size_t size>
char *_strtime(
char (×tr)[size]
); // C++ only
template <size_t size>
wchar_t *_wstrtime(
wchar_t (×tr)[size]
); // C++ only
Parámetros
- timestr
Time string.
Valor devuelto
Returns a pointer to the resulting character string timestr.
Comentarios
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.If timestr is NULL pointer or if timestr is formatted incorrectly, the invalid parameter handler is invoked, as described in Parameter Validation. If the exception is allowed to continue, these functions return a NULL and set errno to EINVAL if timestr was a NULL or set errno to ERANGE if timestr is formatted incorrectly.
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see Secure Template Overloads.
Generic-Text Routine Mappings
TCHAR.H routine |
_UNICODE & _MBCS not defined |
_MBCS defined |
_UNICODE defined |
---|---|---|---|
_tstrtime |
_strtime |
_strtime |
_wstrtime |
Requisitos
Routine |
Required header |
---|---|
_strtime |
<time.h> |
_wstrtime |
<time.h> or <wchar.h> |
For additional compatibility information, see Compatibility in the Introduction.
Ejemplo
// crt_strtime.c
// compile with: /W3
#include <time.h>
#include <stdio.h>
int main( void )
{
char tbuffer [9];
_strtime( tbuffer ); // C4996
// Note: _strtime is deprecated; consider using _strtime_s instead
printf( "The current time is %s \n", tbuffer );
}
The current time is 14:21:44
Equivalente en .NET Framework
Vea también
Referencia
ctime, _ctime32, _ctime64, _wctime, _wctime32, _wctime64