Repeater datepicker getting issues...

Hello,

I’m using dataset to display the date from the database in a datepicker. Datapicker is showing the value correctly sometimes but sometimes shows nothing. Also, in coding it getting null & displaying a 1 Jan 1970. Although, I’ve checked the database & there is date is stored perfectly. Please help me with this.

$w.onReady(() => {
    $w("#totalsumdisplay").html = "<p style='font-size: 25px; font-style: avenir; text-align: right; color: black;'>Calculating...</p>";
    $w('#dataset1').onReady(() => {
         mysum2();
     $w("#repeater1").onItemReady( ($item, itemData, index) => {
           console.log($w('#datePicker1').value);
 var a = new Date($w('#datePicker1').value);
    console.log(typeof(a.getDate()));
    console.log(a);
 var b = new Date($w('#datePicker2').value);
    console.log(b);
 }) 
 })

To refer to an element in the repeater and have it return the value of that repeater item (row), you need to use the repeated-item-scope selector $item instead of $w.

var a =new Date($item('#datePicker1').value);