Stopwatch
class provides access to time with the highest resolution available. You will need to combine calls to Elapsed with single call to DateTime.UtcNow
if you need timestamps similar to JavaScript Date.now.
If you are fine with just DateTime
resolution - check out Function that creates a timestamp in c# - covers many options, including using DateTime
and integer counter to provide timestamps that are sortable and guaranteed to be unique in the single process.
Note: as with most timestamps you can't relay on timestamps created on different machines/process for ordering entries/logs, so picking higher resolution timestamps over simply unique once may not give much benefits.