Hi, I have used this API in cloudscript to get Server Timestamp. I have the response from API and now I want to add hours or minutes in the timestamp I got from API. How can I do that?
GetTime API always returns the time as Coordinated Universal Time(UTC). Do you mean you want to do increasing calculation to the time then return the modified UTC?
CloudScript executes JavaScript code, so you can directly use the following statement to get the current UTC, you can use this native JS method instead of PlayFab API GetTime.
var now = new Date();
So you can use the following function to get the date that current UTC plus one hour.
handlers.plusOneHour = function (args, context) { var now = new Date(); var myTimeStamp = now.setHours(now.getHours() + 1); var myDate = new Date(myTimeStamp); return myDate; };
For more advanced questions about time calculation and formatting time in the CloudScript, please refer to the documentation of JavaScript.
4 People are following this question.