How do I calculate the number of days a user is registered?

How do I calculate the number of days a user is registered?
like

if user join at 01/02/2022 then at 31/01/2023 = 365 day

Using clock component.

3 Likes

what if the date is unknown?

Registered date you mean ? Are you going to use a date picker ?

1 Like
  1. yes
  2. no

Once user is registered you should save registered date to either tinyDB or firebase or any other database you are going to use. In this way you can call registered date when you need it

1 Like

I want to do it, but I'm confused

@dora_paz I think firebase would be great because if user uninstall the app then local data will be deleted.

2 Likes

Are you going to create a signup/login system ?

1 Like

yes, but i will use this for badge

@M.D.M.Aditama to reduce the confusion you need to create unique user ID for each user and for that you can't use random number because there is some possibility of the same number may generate in someone else's device.

1 Like

*this is an offline app

@M.D.M.Aditama if the app is offline then how can you calculate the days.

Let suppose I installed your app today and uninstalled tomorrow then the total days is 1.

Again i installed your app day after tomorrow and uninstalled after 2 days in that case you can't say total days are 2 because I registered today so total days are 3.

For that you need to store data in your database means online using firebase otherwise it will be deleted when user uninstall your app.

2 Likes

it's not a problem, the most important thing is to count the number of days

Then on first run save registered date to tinyDB. Then set a global variable to call tag from tinyDB and do the calculations using clock component

1 Like

how to save it?

Please read

I hope it's the last question

Try something like this

2 Likes


@dora_paz

Ok this would get impossible you have to show your blocks otherwise we wont be able to see where you are going wrong.

1 Like


@Aarush_Kumar @dora_paz