Solved Get seconds in timespan

  • 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.

CommandActor

Member
Mar 3, 2018
1
0
1
34
Hi.
I'm trying to get the seconds in a variable containing a timespan object.

Code:
set {_tdiff} to difference between now and {_start time}
set {_seconds} to seconds in {_tdiff}

The syntax above does not seem to work, I tried other expressions as well, like
Code:
set {_seconds} to {_tdiff} converted to seconds
and
Code:
set {_seconds} to {_tdiff} parsed as number
but they don't work.

Could someone help me out please?
 
Hi.
I'm trying to get the seconds in a variable containing a timespan object.

Code:
set {_tdiff} to difference between now and {_start time}
set {_seconds} to seconds in {_tdiff}

The syntax above does not seem to work, I tried other expressions as well, like
Code:
set {_seconds} to {_tdiff} converted to seconds
and
Code:
set {_seconds} to {_tdiff} parsed as number
but they don't work.

Could someone help me out please?

You would need skript-reflect
Code:
set {_seconds} to {_tdiff}.getTicks() / 20
 
You could use the method above, but you could also do this with vanilla using unix timestamps. Which method you use is up to you:

Code:
set {_t1} to unix timestamp of ({timespan1} ago)
set {_t2} to unix timestamp of ({timespan2} ago)
set {_seconds} to difference of {_t1} and {_t2}
# {_seconds} is the difference between {timespan1} and {timespan2} in seconds
 
Status
Not open for further replies.