Collection Dataset Date format troubles

  1. Wix Collection dataset

  2. dataset with field: ‘deadlineDate’ (field name is Deadlinedate)

  3. Type: Date

  4. Script for a check of the relation between Today’s date and the ‘deadlineDate’

  5. Condition: if (deadlineDateCheck < currentDate) … (see below)

There is still a problem with the DATE format because my Log is about: Invalid format


Standard way:

const deadlinedateCheck = new Date(itemData.deadlinedate);

doesn’t work.

Then incl. moment:

import moment from 'moment';

$w.onReady(function () {
  const currentDate = new Date();

  $w("#dataset1").onReady(() => {
    const dataset = $w("#dataset1");

    $w("#repeater1").onItemReady(($w, itemData, index) => {
      if (index === 0) {
        const deadlineDateCheck = moment(itemData.deadlineDate,'MMM D, YYYY').toDate();
        console.log("Value deadlineDateCheck:", deadlineDateCheck);

        if (deadlineDateCheck < currentDate) {
          $w(`#repeater1`).forEachItem(($item, itemData, index) => {
            if (index === 0) {
              $item("#text80").text = "Finished";
              $item("#text81").text = "";
            }
          });
        }
      }
    });
  });
});

Still the same result.

I’m looking for a way out of this
Thx

J