Get DateTime.Now with milliseconds precision

前端 未结 11 1494
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 16:06

How can I exactly construct a time stamp of actual time with milliseconds precision?

I need something like 16.4.2013 9:48:00:123. Is this possible? I have an applic

11条回答
  •  囚心锁ツ
    2020-11-29 17:00

    As far as I understand the question, you can go for:

    DateTime dateTime = DateTime.Now;
    DateTime dateTimeInMilliseconds = dateTime.AddTicks(-1 * dateTime.Ticks % 10000); 
    

    This will cut off ticks smaller than 1 millisecond.

提交回复
热议问题