Epoch Converter

C Epoch Converter Routines

Epoch / Unix Timestamp Conversion Programming Function in C
 

 Example date routine in C

Example C routine using STRFTIME. STRFTIME converts information from a time structure to a string form, and writes the string into the memory area pointed to by "string".
#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t     now;
    struct tm  ts;
    char       buf[80];

    // Get current time
    time(&now);

    // Format time, "ddd yyyy-mm-dd hh:mm:ss zzz"
    ts = *localtime(&now);
    strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", &ts);
    printf("%s\n", buf);
    return 0;
}
For more information on strftime click here.
Back to Epoch Converter Functions  
 
 
 
Return to the Epoch Converter homepage
© 2008 Misja.com