Two date calculation problems | WordPress.org

[ad_1]

Hello;
I wrote the following code to calculate the 1st date and set the years automatically.

date1 : fieldname14 selected date

date2 : fieldname15 it gets 30/09/YEAR every year.

(function() {
  var current_year = YEAR(TODAY());
  var first_day_year="30/09/" + current_year;

  jQuery('#calculation-first_day_year').html(first_day_year);
  jQuery('.kriter1-aciklama').html('Başlangıç Hesaplama : ');
  jQuery('.kriter1-sonuc').html(GETDATETIMESTRING(first_day_year, 'dd/mm/yyyy'), 'dd/mm/yyyy');
})();

I get the selected date automatically in the 2nd date.

Master calculation code;

(function() {
  var ay = DATEDIFF(fieldname15, fieldname14, 'dd/mm/yyyy', 'y')['months'];

  jQuery('#calculation-ay').html(ay);
  jQuery('.kriter2-aciklama').html('ABC: ');
  jQuery('.kriter2-sonuc').html('<span style="color: orange;">' + ay + '</span>');

  return ay;
})();

where am i doing wrong?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer