Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

Stars 1,019
Forks 115
Open issues 54
PowerShell Gallery downloads 7,576,901
Release v1.41.0
Language: PowerShell Updated: 2026-10-03
Command

New-HTMLDate

Module PSWriteHTML

Outputs a date with a data attribute for live "time ago" calculation or custom display via Moment.js.

Syntax

New-HTMLDate [[-CustomMomentFormat] <String>] [-DoNotIncludeFromNow] [[-Format] <US|EU|24|12|Custom>] [-InputDate] <DateTime> [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Generates a <span> element containing the provided date. - CanonicalFormat is always 'yyyy-MM-dd HH:mm:ss' (used for consistent parsing). - Data attribute "data-format" uses one of the predefined or custom Moment.js formats. - Visible text uses standard .NET formatting. (Or can be changed if desired.)

Examples

Authored help example

EXAMPLE 1

New-HTMLDate -CustomMomentFormat 'Value'

Parameters

-CustomMomentFormat String optionalposition: 2
Only used if -Format is set to 'Custom', e.g. 'dddd, MMMM Do YYYY, h:mm:ss A'
-DoNotIncludeFromNow SwitchParameter optional
Decide whether to display "X minutes/hours/days ago" next to the date.
-Format String optionalposition: 1
Choose one of the predefined format sets or use 'Custom'
Possible values: US, EU, 24, 12, Custom
-InputDate DateTime requiredposition: 0

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.