5

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

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .