共用方式為


SPFieldDateTime.GetFieldValueAsText method (DateTime, SPWeb, SPDateFormat)

傳回指定的欄位的資料值,以國際標準時間 (UTC) 格式,以表示根據指定的日期與時間值、 父 Web 站台,以及SharePoint Foundation日期格式的字串。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Shared Function GetFieldValueAsText ( _
    data As DateTime, _
    web As SPWeb, _
    dateformat As SPDateFormat _
) As String
'用途
Dim data As DateTime
Dim web As SPWeb
Dim dateformat As SPDateFormat
Dim returnValue As String

returnValue = SPFieldDateTime.GetFieldValueAsText(data, _
    web, dateformat)
public static string GetFieldValueAsText(
    DateTime data,
    SPWeb web,
    SPDateFormat dateformat
)

參數

  • data
    Type: System.DateTime

    System.DateTime結構表示,如下所示在 UTC 格式轉換資料值: YYYY-公釐-DDTHH:MM:SSZ.

傳回值

Type: System.String
字串,包含欄位的資料值。

備註

GetFieldValueAsText方法需要日期和時間值是以 UTC 格式,在大部分的SharePoint Foundation方法,傳回清單資料的傳回值以當地時間時。因此,執行時查詢清單資料,您必須轉換時間值,取得預期的結果。若要傳回 UTC 日期和時間項目,使用SPQuery物件,並將DatesInUtc屬性設定為true,,如下列範例所示:

Dim query As New SPQuery()
query.DatesInUtc = true
Dim listItems As SPListItemCollection = list.GetItems(query)
SPQuery query = new SPQuery();
query.DatesInUtc = true;
SPListItemCollection listItems = list.GetItems(query);

請參閱

參照

SPFieldDateTime class

SPFieldDateTime members

GetFieldValueAsText overload

Microsoft.SharePoint namespace