Unix Time (Epoch)

Computer/linux 2010.04.27 23:42

C code (copied from wiki  modified in order to convert a known unix epoch time

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

int main(void)
    time_t     now;
    time_t     old;

    struct tm  *ts;
    struct tm  *ots;
    char       buf[80];
    char       buf2[80];
    /* Get the current time */
    now = time(NULL);
    ts  = localtime(&now);

    strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", ts);
    printf("%s\n", buf);

    old = 1257169741;
    ots = localtime(&old);
    strftime(buf2, sizeof(buf2), "%a %Y-%m-%d %H:%M:%S %Z", ots);
    printf("%s\n", buf2);
    return 0;


* $date -d @1257169741
Mon Nov  2 08:49:01 EST 2009


'Computer > linux' 카테고리의 다른 글

automake & autoconf  (0) 2010.06.26
Unix Time (Epoch)  (0) 2010.04.27
how to get all image files from a http site directory by wget  (0) 2010.04.13
wodim is a command line cd recording tool (linux)  (0) 2010.04.09
posted by citadel