Create a timestamp suitable for Graphite (Unix Epoch).
Get-GraphiteTimestamp [[-Timestamp] <String>] [[-Date] <DateTime>] [[-AddSeconds] <Int32>] [<CommonParameters>]
Calling this function will return a timestamp suitable for Graphite: - If a timestamp is provided it will be parsed and converted. - If no timestamp is provided the current date/time will be used.
$timestamp = Get-GraphiteTimestamp
Write-Host "Current Unix Epoch is: $timestamp"
$timestamp = Get-GraphiteTimestamp -Timestamp '2022-09-07T14:51:57Z'
Write-Host "Unix Epoch for 2022-09-07T14:51:57Z is: $timestamp"
$timestamp = Get-GraphiteTimestamp -Timestamp '1662562317'
Write-Host "Unix Epoch for 1662562317 is, you guessed it...: $timestamp"
$timestamp = Get-GraphiteTimestamp -Date $([DateTime]::Parse('2022-09-07T14:51:57Z'))
Write-Host "Unix Epoch for 2022-09-07T14:51:57Z is: $timestamp"
Specifies the timstamp to parse, if provided.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the date to parse, if provided.
Type: DateTime
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the number of seconds to add to the timestamp. The value can be negative or positive.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.