getServerTime

This operation takes no arguments and returns the NetSuite server time in GMT, regardless of a user's time zone. Developers do not have to rely on client time when writing synchronization procedures because the client time may not be in synch with the NetSuite server time.

If you choose, you can write client code that takes the GMT returned by NetSuite and convert the time to your local time zone. The format of the dateTime value returned by getServerTime contains integer-valued year, month, day, hour and minute properties, a decimal-valued second property and a boolean time-zoned property (timestamp) – for example, 2005-09-21T15:24:00.000-07:00, where 2005-09-21 is the date, 15:24:00.000 is the time and -07:00 is your own time zone offset, if you choose to set one.

Any user with an active session can call getServerTime. There are no explicit permissions for this operation. For example, if you need to synchronize customer data with NetSuite, you can call getServerTime to initialize your synchronization process. To synchronize new or changed customers records, you can search customers and filter by lastModifiedDate using the value returned in getServerTime. To synchronize deleted customer records, you can call the getDeleted operation and use the value returned in getServerTime. This makes your synchronization process independent of your client time,which may not be in sync with the NetSuite server time and hence the timestamp we use to track changes.

Request

The GetServerTimeRequest type is used for the request. It takes no arguments.

Response

The GetServerTimeResponse type is used for the response. It contains the following elements.

Element Name

XSD Type

Notes

response

GetServerTimeResult

See GetServerTimeResult, below.

GetServerTimeResult

The GetServerTimeResult type contains the following elements.

Element Name

XSD Type

Notes

status

Status

The status for this request. All applicable errors or warnings will be listed within this type, which is defined in the platformCore XSD.

serverTime

dateTime

dateTime value returned is in GMT.

Faults

This operation can throw one of the following faults. See SOAP Fault Status Codes for more information on faults.

Sample Code

Java

          public void testGetServerTime() throws Exception
{
   c.login();
 
   GetServerTimeResult rs = c.getPort().getServerTime();
   System.out.println("Welcome to NetSuite. At the sound of the tone the NetSuite time will be : " + new
   SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(rs.getServerTime().getTime()));

   System.out.println("This compares with a client time of " + new SimpleDateFormat("yyyy-MM-dd
   HH:mm:ss").format(Calendar.getInstance().getTime() ));
   System.out.println("This represents a skew of  "  + (Calendar.getInstance().getTimeInMillis()
   rs.getServerTime().getTimeInMillis() )/1000 + " seconds from netsuite
   (where positive time means the client clock is comparatively fast).");
} 

        

Related Topics

General Notices