This is a migrated thread and some comments may be shown as answers.

Server Date

3 Answers 46 Views
JavaScript SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 17 Jan 2015, 07:04 PM
Hi, quick question, is there any way to get the server date using the Javascript SDK?

Thanks,
Daniel

3 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 19 Jan 2015, 05:06 PM
Hi Daniel,

There is no such utility method integrated in the SDK. You can register a Cloud Function that returns new Date to observe the server time. For instance:
Everlive.CloudFunction.onRequest(function(request, response, done) {
    var date = new Date();
    response.body = {Result: date};
    done();
});

A GET request returns a similar formatted result:
{
    "Result": "YYYY-MM-DDTHH:MM:SS.000Z"
}

In addition, could you please specify your use case for such method?

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Daniel
Top achievements
Rank 1
answered on 20 Jan 2015, 09:38 AM
Hi Anton,

Thanks for that, it works well.

The use for the method in my web project is to calculate the difference in months between a given start date which is user defined and the current date, this then allows me to trigger certain events for a bit of gamification.

Thanks again,
Daniel
0
Anton Dobrev
Telerik team
answered on 22 Jan 2015, 08:47 AM
Hi,

Thanks for specifying this.

You might also register another cloud function that handles the calculation itself when called if you do not need to make this client-side.

Please, let me know if you have further questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
JavaScript SDK
Asked by
Daniel
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or