Search code examples
reactjsreact-nativeasyncstorage

AsyncStorage time of creation


So i am storing data in my app using

AsyncStorage.setItem(key, value); 

I was just wondering how i would go about storing the time that this item is added? I want to add a feature where it shows how long ago a status was posted.

My question is: What methods are people using to do this?


Solution

  • When user submitted a status, use Date.now(); to get the current time. Then save it with AsyncStorage. For displaying how long passed from post time, you can use timeago.js .