Get current time in milliseconds, or HH:MM:SS:MMM format

后端 未结 4 627
予麋鹿
予麋鹿 2020-12-01 18:54

I\'ve written a c++ function to get the current time in HH:MM:SS format. How can I add milliseconds or nanoseconds, so I can have a format like HH:MM:SS:M

4条回答
  •  -上瘾入骨i
    2020-12-01 19:30

    Instead of using time() (seconds since the epoch), try gettimeofday(). Gives you a structure that includes a microseconds field.

提交回复
热议问题