time.c 290 B

12345678910111213141516
  1. #include <stdio.h>
  2. #include <sys/time.h>
  3. int main(int argc, char** argv) {
  4. struct timeval time;
  5. int ret = gettimeofday(&time, NULL);
  6. if (ret < 0) {
  7. perror("gettimeofday");
  8. return -1;
  9. }
  10. printf("Current timestamp: %ld\n", time.tv_sec);
  11. return 0;
  12. }