2.1.8.1 asctime


Description

Converts a tm time structure to a character string.

Syntax

char * asctime( TM * timeptr )

Parameters

[input] timeptr, a pointer to TM structure

Return

a pointer to the character string result

Examples

EX1

void asctime_ex1()
{
    struct tm *newtime;
    time_t aclock;
    time( &aclock );                 // Get time in seconds 

    newtime = localtime( &aclock );  // Convert time to struct 
                                    // tm form 
    // Print local time as a string 
    printf( "The current date and time are: %s", asctime( newtime ) );
}

Remark

The timeptr value is usually obtained from a call to localtime, which returns a pointer to a tm structure, defined in time.h. It can be seen more at See Also.

See Also

time, localtime, tm

Header to Include

origin.h

Reference