Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
This question was closed Jul 29, 2020 at 05:44 PM by Muhammad Roshaan Tariq for the following reason: The question is answered, right answer was accepted
avatar image
Question by Muhammad Roshaan Tariq · Jul 22, 2020 at 07:33 AM · apisCloudScriptsdks

Add Hours/Minutes in Current Server Timestamp

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?

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Sarah Zhang · Jul 23, 2020 at 09:53 AM

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.

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Catalog's Item Custom Data 1 Answer

    Entities and Groups - Best practice for obtaining a target player's EntityKey?,Entities for Groups - Best practice for obtain target player's Entity Key? 1 Answer

    How to set up the PlayFab SdkTestingCloudScript git project? 2 Answers

    Playfab Clan/Guild available features and limitations? 2 Answers

    [BUG] PlayFabError "EmailAddressNotAvailable" does not print friendly msg in C# return with Unity 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges