question

max avatar image
max asked

PlayFab C++ Client SDK - Timestamps are in local time instead of UTC Time

We just discovered that all timestamps (e.g. Account creation times) are in localtime, instead of UTC. This is since mktime is used instead of an implementation of mkgmtime.

Is that on purpose? If one changes readDatetime, we also might have to change writeDatatime?

void PlayFab::writeDatetime(time_t datetime, PFStringJsonWriter& writer)
{
    char buff[40];
    strftime(buff, 40, "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&datetime));
    writer.String(buff);
}


time_t PlayFab::readDatetime(const rapidjson::Value& obj)
{
    std::string enumStr = obj.GetString();
    tm timeStruct = {};
    unsigned int milliseconds = 0; // milliseconds are truncated in a standard time_t structure
    sscanf(enumStr.c_str(), "%u-%u-%uT%u:%u%u.%uZ", &timeStruct.tm_year, &timeStruct.tm_mon, &timeStruct.tm_mday,
        &timeStruct.tm_hour, &timeStruct.tm_min, &timeStruct.tm_sec, &milliseconds);
    timeStruct.tm_year -= 1900;
    timeStruct.tm_mon -= 1;
    return mktime(&timeStruct);
}
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The timestamps of events in the Game Manager are based on your profile settings (click on your name in the upper right corner). In terms of times returned to Client API calls, they should all be in UTC. If you're seeing something different, can you clarify what API call you're making?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

max avatar image max commented ·

I'm talking about the timestamps in the C++ Client SDK. For example the account creation date of the player is not in UTC, but in the player's local time. (but every single timestamp is).

0 Likes 0 ·
brendan avatar image brendan max commented ·

I've just created several accounts in my test title, and that's not what I'm seeing. The Created timestamp is the UTC time when the account was created in all my tests. What specific API call are you using, and what parameters are you passing in?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.