Tim Tim - 1 year ago 128
C Question

How do I get the unix timestamp in C as an int?

I would like to get the current timestamp and print it out using fprintf.

Answer Source

For 32-bit systems:

fprintf(stdout, "%u\n", (unsigned)time(NULL)); 

For 64-bit systems:

fprintf(stdout, "%lu\n", (unsigned long)time(NULL)); 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download