Calculating time between two dates

  1. 5 years ago

    henry_cho

    28 Apr 2018 User since 2018

    I'd like to be able to enter two dates and calculate the time between them.
    In swift it seems as though it would be something like this:
    let interval = laterDate.timeIntervalSinceDate(earlierDate)

    I can see ways in gravity to set a date by n seconds from a reference date but not a way to calculate the seconds remaining?
    Thanks H

  2. marco

    28 Apr 2018 Administrator User since 2016

    Hi @henry_cho we'll enhance the Date class in the new upcoming beta release, in the meantime (as a workaround) you can convert both dates in seconds and then compare that value. For example:

    var d1 = Date(); // set to some real date
    var d2 = Date(); // set to some real date
    var diff = d1.second - s2.second;
  3. henry_cho

    28 Apr 2018 User since 2018

    @marco thanks for the help

or Sign Up to reply!