Newer Version Available

This content describes an older version of this product. View Latest

getServerTimestamp()

Retrieves the current system timestamp (Coordinated Universal Time (UTC) time zone) from the API.

Syntax

1GetServerTimestampResult timestamp = connection.getServerTimestamp();

Usage

Use getServerTimestamp() to obtain the current system timestamp from the API. Run this call if, for example, you need to use the exact timestamp for timing or data synchronization purposes. When you create() or update() an object, the API uses the system timestamp to update the CreatedDate and LastModifiedDate fields, respectively, in the object.

The getServerTimestamp() call always returns the timestamp in Coordinated Universal Time (UTC) time zone. However, your local system automatically displays the results in your local time based on your time zone settings.

Development tools differ in the way that they handle time data. Some development tools report the local time, while others report only the Coordinated Universal Time (UTC) time zone. To determine how your development tool handles time values, refer to its documentation.

Note

Sample Code—Java

This sample gets the server time and writes it to the console in the user’s local time zone.

1public void doGetServerTimestamp() {
2   try {
3      GetServerTimestampResult result = connection.getServerTimestamp();
4      Calendar serverTime = result.getTimestamp();
5      System.out.println("Server time is: "
6            + serverTime.getTime().toString());
7   } catch (ConnectionException ce) {
8      ce.printStackTrace();
9   }
10}

Sample Code—C#

This sample gets the server time and writes it to the console in the user’s local time zone.

1public void doGetServerTimestamp()
2{
3   try
4   {
5      GetServerTimestampResult result =
6            binding.getServerTimestamp();
7      DateTime serverTime = result.timestamp;
8      Console.WriteLine("Server time is: " +
9            serverTime.ToLocalTime().ToString());
10   }
11   catch (SoapException e)
12   {
13      Console.WriteLine("An unexpected error has occurred: " +
14                        e.Message + "\n" + e.StackTrace);
15   }
16}

Arguments

None.