This is a simple way:
time_t seconds_since_midnight = time(NULL) % 86400;
To get approximate milliseconds since midnight, multiply seconds_since_midnight
by 1000.
If you need more resolution (consider whether you really do), you will have to use another function such as gettimeofday()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…