Page 1 of 1

Populating DatePicker Component with UTC timestamp

Posted: Wed Jul 15, 2015 8:27 pm
by Mac Strait

Hi,

I have previously used a datapicker component to store user entered date as a UTC timestamp using javascript for returning the value as a UTC as follows:

var tstamp = Date.now();
return tstamp;

I would now like to do the reverse, basically take the stored timestamp (integer) from the database and convert it and set the date picker UI component to that date.

Any suggestions on this?


Populating DatePicker Component with UTC timestamp

Posted: Wed Jul 15, 2015 10:15 pm
by Illya Stepanov

Hi Mac -

You can manipulate the Date(); object with different JavaScript methods the way you need, please refer to documentation here: https://developer.mozilla.org/en-US/d...


Populating DatePicker Component with UTC timestamp

Posted: Thu Jul 16, 2015 7:35 am
by Mac Strait

Hi,

Thanks that is very useful, I think I will create a new date object using the UTC timestamp. Then I will use the Date.prototype methods to get returned the date in the correct format for the date picker UI component.

My question is how do I apply this Javascript in the mapping. Basically I can map the UTC timestamp database value to the datepicker component in the UI. Then I click the JS button and write the javascript to parse the date. Is it just a simple case of having "return parsed_date;" at the end to populate the datepicker UI once I have done the parsing?


Populating DatePicker Component with UTC timestamp

Posted: Thu Jul 16, 2015 4:25 pm
by Mac Strait

Hi,

I found it easier just to invoke a javascript service after the mapping and assign the value there. I have a question about variable expansion. I have the following code in my js:

var Now = new Date();
Apperyio('CashedOut').val(Now);

If I do "Apperyio('CashedOut').val('200'); this displays the value 200 in the text box with name "CashedOut". However what I would like to do is pass the value of variable Now in the call to Apperyio.val.

($Now) doesn't work, I'm not quite sure how to do this. Any guidance would be appreciated.

Thanks


Populating DatePicker Component with UTC timestamp

Posted: Sun Jul 19, 2015 11:08 am
by Alena Prykhodko

Then you should use codeApperyio('CashedOut').val(Now); /code if I understand you correctly.