human readable timestamp in linux kernel
问题 How can I write human readable timestamp in linux kernel? I think do_gettimeofday returns epoch but I don't want to try to convert it to readable time. I just want a format like Hour:Min:Sec:Msec . Thanks 回答1: Later kernels have a function time_to_tm to break epoch time into human readable format. Here's an example: struct timeval t; struct tm broken; do_gettimeofday(&t); time_to_tm(t.tv_sec, 0, &broken); printk("%d:%d:%d:%ld\n", broken.tm_hour, broken.tm_min, broken.tm_sec, t.tv_usec); Again