Converting seconds after epoch into unix time
I have seconds (say x, x is long long data type) after epoch. I wish to convert it into unix time using <ctime> library. The issue is, I want a time_t variable for gmtime() to work, I am unable to make my x(long long) converted to time_t type.

This is what am doing:

//x is number of seconds after epoch, I want that in unix time 

[code]

    time_t t=x; 
    printf("%s\n",asctime(gmtime(&t)));

[/code]

Can I somehow typecast x into time_t ?


Converting seconds after epoch into unix time
===

I have seconds (say x, x is long long data type) after epoch. I wish to convert it into unix time using <ctime> library. The issue is, I want a time_t variable for gmtime() to work, I am unable to make my x(long long) converted to time_t type.

This is what am doing:

//x is number of seconds after epoch, I want that in unix time 

[code]

    time_t t=x; 
    printf("%s\n",asctime(gmtime(&t)));

[/code]

Can I somehow typecast x into time_t ?

