Os.date() question

How would I get the date with os.date(), of the last day in the week?

What do you mean by the last day in the week? Saturday? Sunday?

2 Likes

no like, when the week ends. (Sunday)
I would like to get the date of the next sunday of the current time.

You could use os.date with “%w” to figure out what day it is, then subtract that from 7 to figure out how many days to add.

Edit: Since Roblox considers Sunday to be day 1, you would actually have to subtract from 8. Since this would make Sunday be +7 days, you would want to get the remainder of (8 - weekDay) and 7, so something like (8 - weekDay) % 7.

4 Likes

When you have the number of days until the next Sunday, you would just add that times 86400 to the current time to get that day’s date.

1 Like