( Solved ) How do I Convert TimesTamp to Readable Text ? Offline Earnings

0 favourites
  • 4 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hello

    What I need to do is to get the time user was away ( Elapsed time ) , I already get it with pluging date using date.now , so it brings a big number : 1598578778305 and I subtracted the current date - last date = result some number e.g. 8305 , now how I show the result in set text , to give a user a message , You was away yy/mm/d/h/m/s ? I've been using :

    " zeropad(floor(TimeAwayNumer/60% 60), 2) & ":" & zeropad(floor(TimeAwayNumer%60), 2) "

    but its limited I want to show yy/mm/d/h/m/s .

    thanks

  • Check out the official Date template. It shows how to calculate the difference between two dates (it's in milliseconds), and display it in readable format.

    https://editor.construct.net/#open=date-time

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you dop2000, I had already seen it but I didn't understand it at first, but I looked better and it's quite easy , below the code if someone needs it

    "Time Away : "&ceil(Date.ToTimerHours((Date.Difference(CurrentDate, LocalStorage.ItemValue)) / 8760))&"Y : "&ceil(Date.ToTimerHours((Date.Difference(CurrentDate, LocalStorage.ItemValue) / 730) % 12))&"M : "&ceil(Date.ToTimerHours((Date.Difference(CurrentDate, LocalStorage.ItemValue)/ 24) % 30.417))&"D : "&ceil(Date.ToTimerHours((Date.Difference(CurrentDate, LocalStorage.ItemValue))% 24))&"h : "&ceil(Date.ToTimerMinutes(Date.Difference(CurrentDate, LocalStorage.ItemValue)))&"m : "&ceil(Date.ToTimerSeconds(Date.Difference(CurrentDate, LocalStorage.ItemValue)))&"s"

    The Current date is " date.now " and " Local Storage " is the Last date we get from user when he closes the game " On suspended or End of Layout " , it will get a negative value , you can multiply by -1 to get a positive value

  • here it is the time away ( elapsed time ) working , if someone is interested in make an offline earnings

    construct.net/en/tutorials/display-elapsed-time-timeaway-2561

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