Soenneker.Blazor.Dayjs 11.0.332

Prefix Reserved
dotnet add package Soenneker.Blazor.Dayjs --version 11.0.332
                    
NuGet\Install-Package Soenneker.Blazor.Dayjs -Version 11.0.332
                    
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="Soenneker.Blazor.Dayjs" Version="11.0.332" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Dayjs" Version="11.0.332" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Dayjs" />
                    
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 Soenneker.Blazor.Dayjs --version 11.0.332
                    
#r "nuget: Soenneker.Blazor.Dayjs, 11.0.332"
                    
#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 Soenneker.Blazor.Dayjs@11.0.332
                    
#: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=Soenneker.Blazor.Dayjs&version=11.0.332
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Dayjs&version=11.0.332
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Blazor.Dayjs

A Blazor wrapper around Day.js for relative timestamps and humanized durations, with Razor components for live clocks and countdowns.

Installation

dotnet add package Soenneker.Blazor.Dayjs

Setup

using Soenneker.Blazor.Dayjs.Registrars;

builder.Services.AddDayJsInteropAsScoped();

Initialize the plugins your application uses before rendering a relative-time component or calling the interop service. A layout or other parent component is a convenient place:

@using Soenneker.Blazor.Dayjs.Abstract
@using Soenneker.Blazor.Dayjs.Configuration
@inject IDayJsInterop DayJs

@code {
    protected override async Task OnInitializedAsync()
    {
        await DayJs.Initialize(new DayJsOptions
        {
            LoadRelativeTime = true,
            LoadDuration = true
        });
    }
}

UseCdn defaults to true. Set it to false to load the Day.js files packaged with this library instead of jsDelivr. Initialization is shared by the scoped service, so choose the complete plugin set on the first call.

Components

Add the component namespace to _Imports.razor:

@using Soenneker.Blazor.Dayjs

Relative time

<DayJsRelative Value="article.PublishedAt"
               UpdateInterval="30s" />

This renders values such as 5 minutes ago. It requires LoadRelativeTime. Set WithoutSuffix="true" for text such as 5 minutes, or AutomaticUpdate="false" for a single calculation.

Live clock

<DayJsNow Format="HH:mm:ss" UpdateInterval="1s" />

Format is a .NET date/time format string. Timezone is resolved by .NET's TimeZoneInfo; if omitted, the process/browser local time is used.

Countdown

<DayJsUntil Value="eventStartsAt"
            Format="d.hh:mm:ss"
            UpdateInterval="1s" />

Format is a custom .NET TimeSpan format; colons are escaped for you. Expired countdowns render zero by default. Set ClampToZero="false" to keep displaying a negative duration.

Intervals accept a TimeSpan value or a positive number followed by ms, s, m, h, or d. Invalid and non-positive component intervals fall back to that component's default.

Interop API

Inject IDayJsInterop when you need the value rather than rendered text:

string age = await DayJs.FromNow(article.PublishedAt);
string duration = await DayJs.DurationHumanize(TimeSpan.FromMinutes(90));

FromNow, ToNow, and SubscribeRelative require LoadRelativeTime. DurationHumanize requires LoadDuration. To pass an IANA timezone such as America/Chicago to the relative-time methods, enable both LoadUtc and LoadTimezone.

SubscribeRelative returns an IAsyncDisposable; retain and dispose it when its owner is disposed:

DayJsSubscription subscription = await DayJs.SubscribeRelative(
    article.PublishedAt,
    TimeSpan.FromMinutes(1),
    value => relativeText = value);

await subscription.DisposeAsync();
Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.332 46 12/4/2026
11.0.331 49 12/4/2026
11.0.330 56 12/4/2026
11.0.329 51 12/3/2026
11.0.328 57 12/3/2026
11.0.327 74 12/2/2026
11.0.326 69 12/2/2026
11.0.325 65 12/2/2026
11.0.324 90 12/1/2026
11.0.323 94 11/30/2026
11.0.322 97 11/30/2026
11.0.321 98 11/29/2026
11.0.320 99 11/25/2026
11.0.319 99 11/19/2026
11.0.318 94 11/19/2026
11.0.317 102 11/19/2026
11.0.316 96 11/19/2026
11.0.315 97 11/19/2026
11.0.314 90 11/19/2026
11.0.313 95 11/19/2026
Loading failed

Update dependency Soenneker.Lepton.Suite to 11.0.167 (#999)