5

How do i know the server timestamp using the salesforce REST services ? Simialr to SOAP getServerTimestamp service, do we have any REST service ?

3

There is no such REST API available out of box for the same i guess .I had to implement my own custom REST API class for the same as below

@RestResource(urlMapping='/currentservertime')

 global with sharing class GetCurrentServerDateTime {

global class ResponseWrapper{
    public String currentServerTime;
}

@HttpGet
global static ResponseWrapper returnCurrentServerTime(){    

    dateTime newDate=system.now();      
    String dateInFormat = newDate.formatGMT('yyyy-MM-dd HH:mm:ss');
    ResponseWrapper resWrap=new ResponseWrapper();
    resWrap.currentServerTime=dateInFormat;

    system.debug('Server time being sent:'+dateInFormat);
    return resWrap;
}
}

The urI would be /services/apexrest/currentservertime

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.