question

MoonHeonYoung avatar image
MoonHeonYoung asked

Timezone & return Type question

1. This is a question related to the time zone.

I live in an area where UTC +9:00.

So if I run a new Date() on my local it should work.

But what if I do new Date() in PlayFab CloudScript??

Is this value affected by the region set in my profile-timezone?

In other words, because I set utc+9:00 in my profile,

Are the results of new Date() and Date.now() the same as my local computer and PlayFab cloud environment?

2. I am curious about the types that can be used next to the return of the cloud script.

Looking at other functions Return the object to the client in the same way as return {dd: dd },

but Another function return JSON.stringify(grantedItems);

Returns a string appended with "", such as. Can I use both cases??

What I don't understand is, is it sending jsonized "" strings when communicating with server-client? (JSON.stringify) or sending objects like {dd:dd}?

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

·
Citrus Yan avatar image
Citrus Yan answered
  1. All PlayFab servers report the current time in UTC, you’d need to use standard offsets to adjust the time to your local time zone.
  2. You can use both cases, just make sure that you handle each case properly on the client side, for instance, if you return a stringified JSON object as the result, make sure that you parse it in order to access its values.
4 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.

MoonHeonYoung avatar image MoonHeonYoung commented ·

Thank you for answer.

1. I live in a country of utc +9:00. If so, is it enough to add +9 milliseconds to the value obtained from the cloud code (standard utc)?

2. Is it sending a stringified string when sending a value from the server to the client? If so, is it convenient to return the object from the beginning without having to parse once more in the client?

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan MoonHeonYoung commented ·

You should add +9 hours, and yes, it's more convenient by returning the object.

0 Likes 0 ·
MoonHeonYoung avatar image MoonHeonYoung Citrus Yan commented ·

Sorry for the continued question.

1. Can you tell me how to add + 9 hours to the value returned by utc?

(I'm not familiar with the code)

2. The question is, is the type of data exchanged between the server and the client is string or object type?

(Is it converted to object internally?)

(In other words, I am curious about whether the final type is string like "{dd: dd}")

Is it an object type to send and receive with the server or a string?

0 Likes 0 ·
Show more comments

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.