How do I find time passed since the last launch?

0 favourites
  • 3 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
  • I am trying to find how much time has passed since the last game launch and then convert this value to minutes.

    So, this is what I have done so far:

    1. Game saves current timestamp
    2. Game finds the difference between the saved timestamp and the Date.Now value
    3. The difference is converted to minutes using the ToTimerMinutes expression

    The final expression I use to get elapsed time in minutes looks like this:

    Date.ToTimerMinutes(Date.Difference(JSON.Get("last-launched"), Date.Now))

    However, I am not sure whether this is going to work if more than 60 minutes has passed. Is it going to work if, for example, the last launch date differs for a whole week or even year?

    Furthermore, I wonder what's the use of other expressions such as ToTotalMinutes and GetMinutes in this case and if I better use them.

  • Date.now returns timestamp in milliseconds since 01.01.1970

    To convert it to minutes use this formula:

    minutes=int(Date.now/60000)

    The amount of time passed since last launch in minutes:

    minutes=int((Date.now-lastLaunch)/60000)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Date.now returns timestamp in milliseconds since 01.01.1970

    To convert it to minutes use this formula:

    minutes=int(Date.now/60000)

    The amount of time passed since last launch in minutes:

    minutes=int((Date.now-lastLaunch)/60000)

    Thank you a lot, this is indeed the proper way to solve this problem!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)