Convert os.time to players timezone

Hey everybody, I made it so when a player buys a gamepass, the gamepass works for 30 days and then expires. But I want it to show when the gamepass will expire.

When the player buys the gamepass, “os.time() + 2592000” is added to the datastore, but how do I convert this to the players timezone?

DateTime.FromUnixTimestamp(yourTimeValue):ToLocalTime
Should return a table with .Year .Month etc values based on the local time of the machine running the code.

image
I just get returned this

That is because it returns a table.

print(DateTime.FromUnixTimestamp(yourTimeValue):ToLocalTime.Hour)

This should print the hour of the local timezone.

Look in the documentation from @Wigglyaa for more info.

Thanks, it works.

I did change part of the code though to

print(DateTime.FromUnixTimestamp(yourTimeValue):FormatLocalTime("D/M/YYYY","en-us"))

Not an answer to your question, as that was already solved, but:

Why don’t you just enable private servers for the game, set the price to what you want it to be, and let players do it that way? It lets Roblox handle everything.

Oh, the game is set to paid access, so you can’t enable private servers but I still want players to be able to have their own private server.

Oh I see. That explains why you needed it then!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.