Solved Days since date

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

PatoFrango

Active Member
Jul 12, 2017
240
14
18
Hi,

Is there a way to get the number of days since a specific date (without SkStuff)?

Thanks in advance.

EDIT: Solved

Code:
function daysSince(d: date) :: integer:
    set {_diff} to floor((unix timestamp of now - unix timestamp of {_d}) / 86400)
    return {_diff}
A Unix timestamp is the amount of seconds elapsed since January 1, 1970. If you subtract the current amount of seconds from the amount of seconds of the date you want, and then divide it by 84600 (there are 84600 seconds in a day), you get the number of elapsed days. Since unix timestamps are floats and might not be whole numbers, you should round the result down using floor().
 
Last edited:
Status
Not open for further replies.