Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

UtcTimeFromLocalTime Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online and offline

Retrieves the UTC time for the specified local time.

The relevant classes are specified in the following table.

TypeClass
RequestUtcTimeFromLocalTimeRequest
ResponseUtcTimeFromLocalTimeResponse

Remarks

To use this message, pass an instance of the UtcTimeFromLocalTimeRequest class as the request parameter in the Execute method.

For a list of required privileges, see UtcTimeFromLocalTime Privileges.

Example

The following code example shows how to use the UtcTimeFromLocalTime message.

[C#]
// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request.
UtcTimeFromLocalTimeRequest utcTimeRequest = new UtcTimeFromLocalTimeRequest();

// Get the UTC time for the current local time.
utcTimeRequest.LocalTime = new CrmDateTime();
utcTimeRequest.LocalTime.Value = DateTime.Now.ToString();

// Use the Pacific Standard time zone code.
utcTimeRequest.TimeZoneCode = 4;

// Execute the request.
UtcTimeFromLocalTimeResponse utcTimeResponse = (UtcTimeFromLocalTimeResponse)service.Execute(utcTimeRequest);

// Access the UTC time.
CrmDateTime utcTime = utcTimeResponse.UtcTime;
[Visual Basic .NET]
' Set up the CRM service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the request.
Dim utcTimeRequest As New UtcTimeFromLocalTimeRequest()

' Get the UTC time for the current local time.
utcTimeRequest.LocalTime = New CrmDateTime()
utcTimeRequest.LocalTime.Value = DateTime.Now.ToString()

' Use the Pacific Standard time zone code.
utcTimeRequest.TimeZoneCode = 4

' Execute the request.
Dim utcTimeResponse As UtcTimeFromLocalTimeResponse = CType(service.Execute(utcTimeRequest), UtcTimeFromLocalTimeResponse)

' Access the UTC time.
Dim utcTime As CrmDateTime = utcTimeResponse.UtcTime

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2015 Microsoft