Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

Populating DatePicker Component with UTC timestamp

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?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Populating DatePicker Component with UTC timestamp

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...

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

Populating DatePicker Component with UTC timestamp

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?

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

Populating DatePicker Component with UTC timestamp

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Populating DatePicker Component with UTC timestamp

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

Return to “Issues”