Hi all,
I wanna setup time so that it move like "watch". I try to use Timer Extension, but it fails. how to do that?
Best regards
Ketut
Timer Extension
Moderator: jeanmichel
Timer Extension
- Attachments
-
- timer.png (2.59 KiB) Viewed 6954 times
- jeanmichel
- Posts: 109
- Joined: 23 May 2014, 11:37
- Location: Sydney
Re: Timer Extension
Hi Ketut,
It will not be possible to query the date from the server every second. The easiest option is to read the date field by identifying it and naming it. You can then use the timer extension to +1 sec every second. So it's not the real time but it should be the same as on the server ....
Our recommendation implementing the above is following:
Name the date field as init_time.
Set the timer tick interval to 1000 (1 sec) and then put code below to ontick property
var stf = FIELDS('init_time');
var s = stf.getProperty('value');
console.log('from: input:' + s);
if ( !AXES._sdate ) {
AXES._sdate = new Date(s);
AXES._edate = new Date(AXES._sdate.valueOf() + 1000);
} else {
AXES._edate = new Date(AXES._edate.valueOf() + 1000);
}
var n = AXES._edate.toLocaleDateString()+ ' ' + AXES._edate.toLocaleTimeString();
console.log( n );
stf.setProperty('value',n);
stf.refresh();
here a reference for javascript date function if he need more date information. https://www.w3schools.com/jsref/jsref_obj_date.asp
It will not be possible to query the date from the server every second. The easiest option is to read the date field by identifying it and naming it. You can then use the timer extension to +1 sec every second. So it's not the real time but it should be the same as on the server ....
Our recommendation implementing the above is following:
Name the date field as init_time.
Set the timer tick interval to 1000 (1 sec) and then put code below to ontick property
var stf = FIELDS('init_time');
var s = stf.getProperty('value');
console.log('from: input:' + s);
if ( !AXES._sdate ) {
AXES._sdate = new Date(s);
AXES._edate = new Date(AXES._sdate.valueOf() + 1000);
} else {
AXES._edate = new Date(AXES._edate.valueOf() + 1000);
}
var n = AXES._edate.toLocaleDateString()+ ' ' + AXES._edate.toLocaleTimeString();
console.log( n );
stf.setProperty('value',n);
stf.refresh();
here a reference for javascript date function if he need more date information. https://www.w3schools.com/jsref/jsref_obj_date.asp
Regards,
Jean-Michel Rapin
LANSA Pty Ltd
email: JeanMichel.Rapin@lansa.com.au
Address: 122 Arthur Street, North Sydney, NSW 2060, Australia
Tel: +61 289 070 262 http://www.lansa.com | http://blog.lansa.com |
Jean-Michel Rapin
LANSA Pty Ltd
email: JeanMichel.Rapin@lansa.com.au
Address: 122 Arthur Street, North Sydney, NSW 2060, Australia
Tel: +61 289 070 262 http://www.lansa.com | http://blog.lansa.com |
Re: Timer Extension
Hi JM
is timer extension put directly to date field or I should add user field first?
regards
Ketut
is timer extension put directly to date field or I should add user field first?
regards
Ketut
- jeanmichel
- Posts: 109
- Joined: 23 May 2014, 11:37
- Location: Sydney
Re: Timer Extension
Hi Ketut,
You should add a user field first.
You should add a user field first.
Regards,
Jean-Michel Rapin
LANSA Pty Ltd
email: JeanMichel.Rapin@lansa.com.au
Address: 122 Arthur Street, North Sydney, NSW 2060, Australia
Tel: +61 289 070 262 http://www.lansa.com | http://blog.lansa.com |
Jean-Michel Rapin
LANSA Pty Ltd
email: JeanMichel.Rapin@lansa.com.au
Address: 122 Arthur Street, North Sydney, NSW 2060, Australia
Tel: +61 289 070 262 http://www.lansa.com | http://blog.lansa.com |