C language how to obtain the current timestamp

C language how to obtain the current timestamp
/*
Get current Unix timestamp in C language
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/unistd.h>

#include <sys/time.h>

long long current_timestamp() {
    struct timeval te;
    gettimeofday(&te, NULL); // get current time
    long long milliseconds = te.tv_sec*1000LL + te.tv_usec/1000;
    return milliseconds;
}

int main(){
    long long curtime;
    curtime = current_timestamp();
    printf("Current timestamp:%lld",curtime);
    return 0;
}
Sour‮‬ce:www.lautturi.com
Created Time:2017-08-29 04:24:49  Author:lautturi