How do you make a timeplayed badge

So I have a vibe game, and I just wanna make a badge for the players, and I want a time for each for example: 1 hour 1 day, I have searched in youtube/devforum and I couldn’t find an issue like this, please help me.

Hi PixeledDev!

I would go about this by creating a datastore to store how long the user plays during a session. Every time a player leaves you can figure out the time played and add that to their total time played to get how long they’ve played your game cumulatively.

All of this is possible with the os. API in ROBLOX Lua. Wiki Doc

You can use os.date(*t) which will return a dictionary with fields such as the year, month, day, hour, minute, second, etc.

You can then use os.difftime(TIME1, TIME2) to which will return the number of seconds between the two times.

I will let you figure out the formatting part. (Hint: it can be found on the wiki page too!)
There are also multiple forum posts regarding this topic.