SPRelativeDateTime.GetRelativeDateTimeJavaScriptString method
Gets a string representing the relative value of a DateTime. The string should be parsed by the javascript method GetRelativeDateTimeString().
Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Shared Function GetRelativeDateTimeJavaScriptString ( _
web As SPWeb, _
nowUTC As DateTime, _
localThen As DateTime, _
bIncludeTime As Boolean _
) As String
'Usage
Dim web As SPWeb
Dim nowUTC As DateTime
Dim localThen As DateTime
Dim bIncludeTime As Boolean
Dim returnValue As String
returnValue = SPRelativeDateTime.GetRelativeDateTimeJavaScriptString(web, _
nowUTC, localThen, bIncludeTime)
public static string GetRelativeDateTimeJavaScriptString(
SPWeb web,
DateTime nowUTC,
DateTime localThen,
bool bIncludeTime
)
Parameters
web
Type: Microsoft.SharePoint.SPWebThe current [SPWeb]
nowUTC
Type: System.DateTimeThe current time in UTC, typically DateTime.NowUTC. A fixed value can be used for testing.
localThen
Type: System.DateTimeThe [DateTime] to get a relative string for, in the user's local time.
bIncludeTime
Type: System.BooleanTrue if the return value is to include the time of day. False for DateOnly. Note: not all output values will include the full time.
Return value
Type: System.String
The return value is in the form mode|args mode=0: Special case where args is passed through as the display text mode=1: Standard friendly relative display mode, eg "In 3 hours" Format: mode|bFuture|bucket|args bFuture refers to if localThen is at a later time than nowUTC bucket is the type of string to output args contains the values to plug into the string referenced by the bucket