Languages
[Edit]
EN

C# / .NET - DateTime.Now precision

9 points
Created by:
Marcin
15740

Using DateTime structure in C# / .NET it is possible make operations with maximal precision 100 ns, so it is impossible to see difference during operating on times that are smaller than 100 ns.

DateTime.Now property precision example

DateTime now = DateTime.Now;

Console.WriteLine($"{now:o}");

Output:

2019-08-20T21:38:06.2885653+01:00

Where:

  • 2019 - year
  • 08 - month (August)
  • 20 - day of month
  • 21 - hour
  • 38 - minute
  • 06 - second
  • 288 - millisecond part (from: ...2885653...)
  • 565 - microsecond part (from: ...2885653...)
  • 300 - nanosecond part (from: ...2885653...)
  • +01:00 - time offset (GMT+1)
Note: as it has been shown it is possible only to get multiple of one hundred of nanoseconds of DateTime

References

  1. DateTime.Now Property - Microsoft Docs
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join