Query options usage (4): UTC time processing

Source: Internet
Author: User
Tags time zones

next to the previous article query options usage (3): Paging , this article also introduces lists. dateinutc already exists in the getlistitems method document.

Dateinutc

TrueTo return dates in Coordinated Universal Time (UTC) format.FalseTo return dates in ISO format. This element is optional, andIts default value isFalse. (Note: This document is incorrect in the sharepoint2010 environment. The default value is false. See the following example .)

 

First, run the method without passing in query options.

Static VoidMain (String[] ARGs)

{

 

ListsClient =New Lists();

Client. url = weburl +"/_ Vti_bin/lists. asmx";

Client. Credentials = system. net.Credentialcache. Defaultcredentials;

XmlnodeResultnode = client. getlistitems (listname,String. Empty, queryall, viewfields,"1",Null,String. Empty );

Console. Readline ();

}

The following result is displayed. Check the creation and modification time. The UTC time is not used, so the default value is false.

<RS: Data itemcount = "1" listitemcollectionpositionnext = "paged = true & amp; p_id = 1" xmlns: rs = "urn: Schemas-Microsoft-com: rowset">

<Z: Row ows_title = "test01" ows_attachments = "1" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 1; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 1 "ows_uniqueid =" 1; # {E1F2046C-16AC-4650-8EE3-73E12ED5E833} "ows_owshiddenversion =" 4 "ows_fsobjtype =" 1; #0"Ows_created = "2012-11-30 15:37:17"Ows_permmask = "0x7fffffffffffffff"Ows_modified = "10:42:20"Ows_fileref = "1; # teams/smetechcom/lists/queryoptionsdemo/mirror.000" xmlns: z = "# rowsetschema"/>

</RS: DATA>

Here, I use<Dateinutc> false </dateinutc>Verify and find that.

Static XmlnodeQueryoptions

{

Get

{

XmlelementQueryoptions = _ camldoc. createelement ("Queryoptions");

Queryoptions. innerxml ="<Dateinutc> false </dateinutc>";

ReturnQueryoptions;

}

}

Static VoidMain (String[] ARGs)

{

 

ListsClient =New Lists();

Client. url = weburl +"/_ Vti_bin/lists. asmx";

Client. Credentials = system. net.Credentialcache. Defaultcredentials;

XmlnodeResultnode = client. getlistitems (listname,String. Empty, queryall, viewfields,"1", Queryoptions,String. Empty );

Console. Readline ();

}

<RS: Data itemcount = "1" listitemcollectionpositionnext = "paged = true & amp; p_id = 1" xmlns: rs = "urn: Schemas-Microsoft-com: rowset">

<Z: Row ows_title = "test01" ows_attachments = "1" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 1; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 1 "ows_uniqueid =" 1; # {E1F2046C-16AC-4650-8EE3-73E12ED5E833} "ows_owshiddenversion =" 4 "ows_fsobjtype =" 1; #0"Ows_created = "2012-11-30 15:37:17"Ows_permmask = "0x7fffffffffffffff"Ows_modified = "10:42:20"Ows_fileref = "1; # teams/smetechcom/lists/queryoptionsdemo/mirror.000" xmlns: z = "# rowsetschema"/>

</RS: DATA>

Finally, set the display UTC time to see if the results are different.

Static XmlnodeQueryoptions

{

Get

{

XmlelementQueryoptions = _ camldoc. createelement ("Queryoptions");

Queryoptions. innerxml ="<Dateinutc> true </dateinutc>";

ReturnQueryoptions;

}

}

 

<RS: Data itemcount = "1" listitemcollectionpositionnext = "paged = true & amp; p_id = 1" xmlns: rs = "urn: Schemas-Microsoft-com: rowset">

<Z: Row ows_title = "test01" ows_attachments = "1" ows_author = "1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_editor =" 1; # Qin, lei (Lambert, es-apps-Gd-China-SH) "ows_metainfo =" 1; # "ows _ moderationstatus =" 0 "ows _ Level =" 1 "ows_id =" 1 "ows_uniqueid =" 1; # {E1F2046C-16AC-4650-8EE3-73E12ED5E833} "ows_owshiddenversion =" 4 "ows_fsobjtype =" 1; #0"Ows_created = "2012-11-30t07: 37: 17z"Ows_permmask = "0x7fffffffffffffff"Ows_modified = "2012-12-13t02: 42: 20z"Ows_fileref = "1; # teams/smetechcom/lists/queryoptionsdemo/mirror.000" xmlns: z = "# rowsetschema"/>

</RS: DATA>

 

Why do we need UTC time?

In my opinion, the main problem to be solved is the problem of different time zones. In Sharepoint, the interface displays local time. Each user can modify his/her display time zone. For example

For developers, once you ignore the time zone and use your local time zone to query the site data in a different time zone, the number of query results may be faulty.

Therefore, we recommend that you use this option for each query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.