UtcMilliTime 3.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package UtcMilliTime --version 3.0.1
                    
NuGet\Install-Package UtcMilliTime -Version 3.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UtcMilliTime" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UtcMilliTime" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="UtcMilliTime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UtcMilliTime --version 3.0.1
                    
#r "nuget: UtcMilliTime, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UtcMilliTime@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UtcMilliTime&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=UtcMilliTime&version=3.0.1
                    
Install as a Cake Tool
JPKusumi.com presents—

UtcMilliTime

UtcMilliTime is a C# time component (software-defined clock) that yields Unix time milliseconds (Int64) timestamps, similar to JavaScript's Date.now(). It synchronizes with NTP servers and is cross-platform for .NET 8+.

Version 3 is thread-safe and introduces NowNonce() — a 12-byte value (8-byte timestamp + 4-byte entropy) designed for cryptographic use cases such as nonces in encryption or JWT handling.

On NuGet at: https://www.nuget.org/packages/UtcMilliTime/
On GitHub at: https://github.com/JPKusumi/UtcMilliTime-3.x

What's New in v3.0

  • NowNonce(), TimestampFromNowNonce(), and EntropyFromNowNonce() methods
  • Thread safety improvements across the Clock singleton
  • Consolidated into a single feature file for easier maintenance
  • Prepared for both normal and source-only NuGet packaging

See the CHANGELOG for the full version history.

Overview

UtcMilliTime provides Int64 timestamps (milliseconds since 1/1/1970 UTC). It initializes with device time and can optionally synchronize with NTP servers. The clock uses a singleton pattern so that all parts of an application share the same time source.

Installation

dotnet add package UtcMilliTime

Basic Usage

using UtcMilliTime;

var clock = Clock.Time;
clock.SuppressNetworkCalls = false;     // Allow NTP synchronization

long timestamp = clock.Now;
string iso = timestamp.ToIso8601String();

// New in v3
byte[] nonce = clock.NowNonce();
long ts = clock.TimestampFromNowNonce(nonce);
uint entropy = clock.EntropyFromNowNonce(nonce);

Thread Safety (v3)

Version 3 includes thread safety improvements, particularly around concurrent access and network synchronization.

Notes

  • By default, SuppressNetworkCalls = true (uses only device time).
  • Call SelfUpdateAsync() manually or set SuppressNetworkCalls = false to enable NTP sync.
  • The NetworkTimeAcquired event can be used to react to successful synchronizations.

Resources

For more information and updates, visit JPKusumi.com.

Discussion and feedback: GitHub Discussions

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.0 146 6/26/2026
3.0.2 116 6/19/2026
3.0.1 118 6/19/2026
3.0.0 117 6/19/2026
2.2.3 171 2/4/2026
2.2.2 131 2/4/2026
2.2.1 129 2/3/2026
2.2.0 132 2/3/2026
2.1.0 256 11/6/2025
2.0.0 210 7/11/2025
1.0.1 2,578 10/28/2019

Version 3.0.1: Fixed package description on NuGet. Includes all v3.0.0 features (thread safety + NowNonce support).