Get DateTime.Now with milliseconds precision

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

    If you still want a date instead of a string like the other answers, just add this extension method.

    public static DateTime ToMillisecondPrecision(this DateTime d) {
        return new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute,
                            d.Second, d.Millisecond, d.Kind);
    }
    

提交回复
热议问题