Checking day of week in script

The title pretty much explains my problem. I want to have it so at some point in the day (the time doesn’t really matter) something updates based on a table similar to this:

Local updateschedule = {
    ["Monday"] = {} --information about what happens on mondays
    ["Tuesday"] ={} --info for Tuesdays.
---and so forth for all 7 days
}

I want each server, when first started, to check the day it is and look at the table to update what needs to be updated. Also, when a day is finished and a new day starts to do the same. I considered using os.time but I’m not sure if I can use to check what day it is. Any suggestions or corrections?

6 Likes

os.date can be used to find the day easily

os.date("*t").wday

that will equal the day

os.date("*t").wday can be a number from 1 - 7

1 being sunday, 4 being wednesday, and 7 is obviously saturday
this is because it is Sunday - Saturday

now before you use this let me explain something
you can either have local time or UTC time

local time
os.date("*t").wday
UTC time
os.date("!*t").wday

hope I helped

9 Likes

if you want the string instead of a number you can do

os.date("%A")

I don’t know if this is local time or UTC
but this will return the full name

such as Wednesday

os.date("%a")

the lower case “a” will show an abbreviated name

such as Wed

3 Likes

if you want more information about os.date() I recommend going here
you can get so much information with the date and time

1 Like