在Linux中,可以使用C语言的time.h库来获取系统时间
#include<stdio.h>
#include <time.h>
int main() {
    time_t currentTime;
    struct tm *localTime;
    // 获取当前的系统时间(以秒为单位)
    currentTime = time(NULL);
    // 将系统时间转换为本地时间(struct tm格式)
    localTime = localtime(¤tTime);
    // 打印本地时间
    printf("当前本地时间:%s", asctime(localTime));
    return 0;
}
这个程序首先获取当前的系统时间(以秒为单位),然后将其转换为本地时间(struct tm格式),最后使用asctime()函数将本地时间转换为可读的字符串并打印出来。