ConvertFromAFRelativeTime Class
- Last UpdatedDec 15, 2025
- 3 minute read
Converts a PI Time string into a DateTime
The ConvertFrom-AFRelativeTime cmdlet will convert a relative time into a DateTime and optionally translate it into local or UTC time.
By default the returned timestamp will not have a timezone associated with it.
Inheritance Hierarchy
InternalCommand
Cmdlet
PSCmdlet
OSIsoft.PowerShellOSICmdletBase
OSIsoft.PowerShellConvertFromAFRelativeTime
Namespace: OSIsoft.PowerShell
Assembly: OSIsoft.PowerShell (in OSIsoft.PowerShell.dll) Version: 3.1.1.0 (3.1.1.466)
Syntax
[CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess = true)] [AliasAttribute(new string[] { ... })] public class ConvertFromAFRelativeTime : OSICmdletBase
<CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess := true)> <AliasAttribute(New String() { ... })> Public Class ConvertFromAFRelativeTime Inherits OSICmdletBase Dim instance As ConvertFromAFRelativeTime
[CmdletAttribute(L"ConvertFrom", L"AFRelativeTime", SupportsShouldProcess = true)] [AliasAttribute(__gc new array<String^>^ { ... })] public ref class ConvertFromAFRelativeTime : public OSICmdletBase
[<CmdletAttribute("ConvertFrom", "AFRelativeTime", SupportsShouldProcess = true)>] [<AliasAttribute(new string[] { ... })>] type ConvertFromAFRelativeTime = class inherit OSICmdletBase end
The ConvertFromAFRelativeTime type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| ConvertFromAFRelativeTime |
Properties
| Name | Description | |
|---|---|---|
| LocalTime | Force the returned timestamp to be in local time | |
| RelativeTime | The PI Time string to convert to DateTime. For example: "*" or "*-2h" or "*+1d" | |
| UtcTime | Force the returned timestamp to be in UTC time |
Examples
ConvertFrom-AFRelativeTime -RelativeTime "*"This example will return a System.DateTime for the current time in UTC.
Examples
ConvertFrom-AFRelativeTime -RelativeTime "*-2h"This example will return a System.DateTime for "two hours ago" in UTC.
Examples
ConvertFrom-AFRelativeTime -RelativeTime "T+8h -LocalTime"This example will return a System.DateTime for "today at 8am" in the local machine's time zone.
Examples
Get-PIValue -PointName "Sinusoid" -Time (ConvertFrom-AFRelativeTime -RelativeTime "*") -ArchiveMode Interpolated -Connection $con
This example uses the ConvertFrom-AFRelativeTime cmdlet to get the interpolated value of tag "sinusoid" at the current time.