# [Plugin] System date and time

Post your completed addons to share with the community

### » Fri Jan 01, 2016 5:16 pm

@rexrainbow - are t0 and t1 in scale of days? How do I tell it with an expression to calculate the day,month and year of t1 and t0?

This is very confusing, can you post an example?
Do I convert t0 and t1 to a unix timestamp values, then calculate the difference and convert back to normal timestamp?
What is the expression to convert back to normal?
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

### » Sun Jan 03, 2016 12:24 am

@blurymind

No, t0 and t1 is milliseconds.
T = (t1 - t0)/1000 : seconds
T/60 : minutes
T/(60*60) : hours
T/(60*60*24) : days
Goodbye
B
113
S
30
G
295
Posts: 4,549
Reputation: 164,483

### » Sun Jan 03, 2016 9:39 am

And how do i get t0 and t1?
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

### » Mon Jan 04, 2016 12:21 am

@blurymind

Ony way to get t0, t1 is using Expression:UnixTimestamp to get current timestamp.
Or get specific timestamp by Expression:Date2UnixTimestamp(year, month, day)
Goodbye
B
113
S
30
G
295
Posts: 4,549
Reputation: 164,483

### » Tue Jan 05, 2016 12:17 am

Thank you, the formula worked!

Now on to figure out a user intuitive way to input the date.
B
40
S
15
G
4
Posts: 426
Reputation: 5,870

### » Sat Jan 23, 2016 6:40 pm

Hi Rex,

I am using your plugin 'Date' and 'DateInARow'. Which plugin do you think will allow me to count the days that my game has been in use. For example, from day 1 of installing the game to the current date, something like you have been using this game for number of days. Its just for stats really. Is this at all possible. I have managed to get the date number and store that locally, then subtract if from the new date, but as soon as it goes into following month the calculation are out. Any ideas would be great.

Thanks John
B
6
Posts: 17
Reputation: 284

### » Sun Jan 24, 2016 3:04 am

@johnhenderson196

Uses rex_date plugin ,and save (year, month, date).
Compare current date (year, month, date) with saved (year, month, date). If any of these 3 fields is different, then it is a new day now.
Goodbye
B
113
S
30
G
295
Posts: 4,549
Reputation: 164,483

### » Sun Jan 24, 2016 12:25 pm

Thanks for that Rex,

And for taking the time to respond. I have one query, that is, I can use the Browser plugin and store the date in a cookie, I presume as you have done in your capx examples. Or can I use the localstorage to save the date. Having read the manual it is possible for the user to remove all cookies on the device, thus removing the saved date. It sounds like local storage would be the securest option to use. I think unless any one else knows differently.

John
B
6
Posts: 17
Reputation: 284

### » Sun Jan 24, 2016 3:00 pm

@johnhenderson196

I prefer saving data in webstorage/localstorage.
Goodbye
B
113
S
30
G
295
Posts: 4,549
Reputation: 164,483

### » Sun Jan 24, 2016 3:11 pm

Cool thanks Rex it makes much more sense
B
6
Posts: 17
Reputation: 284

PreviousNext