Walter Lee6162535
Posts: 0
Joined: Wed Aug 21, 2013 5:49 am

How to log a timestamp ?

Hi,

I am writing an app for early stroke signs for non-English speaking.
One feature I like is to log the timestamp when they hit a button so they can show the doctor later the time they suspect.

Any code sample ? example ? to save this in a label or something, so it can persist later when they arrive at the hospital and open the app again ?

I am very beginner, so the more code/example the better !

Thank you!

Walter

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How to log a timestamp ?

Hi Walter,

You can save timestamp in localStorage on button click, and then show it.

Examples:
1) To get timestamp, and save it run:
codelocalStorage.setItem('mytime',new Date().getTime());/code
2) To get timestamp value run:
codelocalStorage.getItem('mytime');/code
Or better you can save a local variable value in Label in appery UI. For any event choose setProperty action, for Label component select "read from local storage variable" where specify the variable name, such as in the example above - "mytime".

Walter Lee6181771
Posts: 0
Joined: Tue Aug 27, 2013 6:50 am

How to log a timestamp ?

Hi, Katya,

I followed the steps and make a new button to run JS below when clicked,

{
localStorage.setItem('mytime',new Date());

var timestamp = localStorage.getItem('mytime');
Appery('StroketimeLable').text((timestamp));
}

I can see the label has
"Sat Sep 14 2013 02:34:40 GMT-0700 (Pacific Daylight Time)"

timestamp !

Thank you!

So, this will stay and be seen again even the app was closed and later again when needed. It is used to record the stroke patient stroke timestamp and need to show the ER doctor later . So, this q.

Thank you!

Walter

Walter Lee6162535
Posts: 0
Joined: Wed Aug 21, 2013 5:49 am

How to log a timestamp ?

I just tested and the timestamp will be lost going from this page to another.
Please help me to save it as a persistent data .
The more code example the better for me .
Thank you.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How to log a timestamp ?

You could try to create new JS file. In JS file create new function with code which you posted above and call this function on button click event.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

How to log a timestamp ?

Just to add, local storage data is persisted between page navigation and also if you restart the browser.

Walter Lee6162535
Posts: 0
Joined: Wed Aug 21, 2013 5:49 am

How to log a timestamp ?

thanks !
I figured it out.
I forgot to load it when page reload, so it did not show up.
It is persistent across the pages and restart !

Excellent !
Thank you !

Return to “Issues”