Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
getServerTimestamp()
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.
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.