OS Date (Need Help)

So I have this script with os date

local age = player.AccountAge
local joinTime = os.time() - (age*86400)
local joinDate = os.date("!*t", joinTime)
print(joinDate.day, joinDate.month, joinDate.year)

When i try, it result like 30 7 2021 or 20 2 2020, how to make it 30 July 2021 or 20 Feb 2020 etc. So the month change into word string.

I assume this isn’t the full script, otherwise you should define player too. You can find more information on string formatting here in terms of os.

Also, are you looking for the full month name or the abbreviation of the month name here? In this example, I used the full month name.

local age = player.AccountAge
local joinTime = os.time() - (age*86400)
local joinDate = os.date("%d %B %Y", joinTime)
print(joinDate)

-- in this case an example of what joinDate will be would be something like 1 November 2009

Thanks for answering. [chars limit…]

1 Like

Bare in mind that when a specifier (format option) other than “!*t” is used the returned formatted time & date string will vary according to the locale (local time). You can continue following UTC time by doing the this.

local players = game:GetService("Players")
local player = players.LocalPlayer
local playerAge = player.AccountAge

local days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
local months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}

local joinTime = os.time() - (playerAge * 86400)
local joinDate = os.date("!*t", joinTime)
print(days[joinDate.wday], months[joinDate.month], joinDate.year)