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

后端 未结 5 497
借酒劲吻你
借酒劲吻你 2020-12-07 22:05

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

5条回答
  •  猫巷女王i
    2020-12-07 22:49

    #include 
    #include 
    
    int main ()
    {
       time_t seconds;
    
       seconds = time(NULL);
       printf("Seconds since January 1, 1970 = %ld\n", seconds);
    
       return(0);
    }
    

    And will get similar result:
    Seconds since January 1, 1970 = 1476107865

提交回复
热议问题