viewing paste Unknown #675 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13
char* timer_getcurDate(){
        time_t rawtime;  // variable for number of seconds (used with time() function)
    struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
    char *temp = malloc(sizeof(char)*512);
        if(temp){
            time(&rawtime);  // get time in seconds since 1/1/1970
            datetime = localtime(&rawtime); // convert seconds in structure
            // like sprintf, but only for date/time (Sunday-November-02-2003-15:12:52)
            strftime(temp, sizeof(temp)-1, "%A, %B %d %Y %X", datetime);
            return temp;
        }
        return NULL;
}
Viewed 1337 times, submitted by lighta.