Newer Version Available
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. You might do this 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 might automatically display the results in your local time based on your time zone settings.
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.