UtcMilliTime 3.0.0
See the version list below for details.
dotnet add package UtcMilliTime --version 3.0.0
NuGet\Install-Package UtcMilliTime -Version 3.0.0
<PackageReference Include="UtcMilliTime" Version="3.0.0" />
<PackageVersion Include="UtcMilliTime" Version="3.0.0" />
<PackageReference Include="UtcMilliTime" />
paket add UtcMilliTime --version 3.0.0
#r "nuget: UtcMilliTime, 3.0.0"
#:package UtcMilliTime@3.0.0
#addin nuget:?package=UtcMilliTime&version=3.0.0
#tool nuget:?package=UtcMilliTime&version=3.0.0
| 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(), andEntropyFromNowNonce()methods- Thread safety improvements across the
Clocksingleton - 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 setSuppressNetworkCalls = falseto enable NTP sync. - The
NetworkTimeAcquiredevent 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 | Versions 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. |
-
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.