How to stop displaying widget after certain date and time

If you want to stop displaying your widget after certain date and time, this code is just what you need:

<script
  src="https://static.elfsight.com/platform/platform.js"
  data-use-service-core
  defer
></script>
<script id="elfsight-custom-script">
  var targetDate = "2023 July 06, 14:35 UTC+3";
  window.addEventListener("DOMContentLoaded", function () {
    var currentDate = new Date().getTime() / 1000;
    var endDate = new Date(targetDate).getTime() / 1000;
    var block = document.getElementById("elfsight-custom-script").parentNode;
    var widget =
      '<div class="elfsight-app-WIDGET-ID"></div>';
    if (currentDate > endDate) return;
    block.insertAdjacentHTML("beforeend", widget);
  });
</script>

Do not forget to add the needed date and time after var targetDate = and replace Widget-ID with your actual widget ID


Guys, if you have further questions or any assistance is needed, let us know in the comments. We are all ears :slightly_smiling_face: