Get DateTime.Now with milliseconds precision

前端 未结 11 1476
没有蜡笔的小新
没有蜡笔的小新 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 16:53

    public long millis() {
      return (long.MaxValue + DateTime.Now.ToBinary()) / 10000;
    }
    

    If you want microseconds, just change 10000 to 10, and if you want the 10th of micro, delete / 10000.

提交回复
热议问题