How do I Count Days ?

Get help using Construct 2

Post » Tue Aug 26, 2014 3:12 am

Hey guys,

I want to count how many day passed. I know Ejectjs date but I couldn't figure out how to use it to substract my start date.

if anybody have idea to make it, I really appreciate, thank you.
Image
B
63
S
28
G
39
Posts: 460
Reputation: 24,187

Post » Tue Aug 26, 2014 4:29 am

You'll have to use this plugin to get the date:
http://c2rexplugins.weebly.com/rex_date.html

on the start date save the UnixTimestamp (seconds since Jan 1, 1970) to webstorage for later, we'll call this start_time.

Then any following times you want to see how many days have passed you retrieve the saved time from webstorage and subtract the current UnixTimestamp. That will give you the number of seconds from one date to another. Divide by 60 to get minutes, 60 again to get hours, and finally also by 24 to get days.

days = (start_time - UnixTimestamp)/60/60/24
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Tue Aug 26, 2014 5:08 am

@R0J0hound you are AWSOME! I did it :D

Like this : floor(UnixTimestamp-start_time)/1000/60/60/24)

Thank you! I was searching for like 1 hour.

And @rexrainbow thank you for the plugin!
Last edited by bilgekaan on Tue Aug 26, 2014 5:16 am, edited 1 time in total.
Image
B
63
S
28
G
39
Posts: 460
Reputation: 24,187

Post » Tue Aug 26, 2014 5:14 am

Opps... I see I had the subtraction reversed. :p Glad you got it working.

cheers
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 52 guests