Predefine date | WordPress.org

[ad_1]

Hello @itzikn,

Thank you very much for using our plugin. I’ll try to describe the process with a hypothetical example. Assuming the date fields are fieldname1 and fieldname2, respectively, and their date format is mm/dd/yyyy.

Insert a calculated field in the form and enter the following piece of code as its equation (The calculated field can be hidden by ticking a checkbox in its settings):


(function(){
let first = TODAY(),
last = EOMONTH(TODAY());

first.setDate(1);

getField(fieldname1|n).setVal(GETDATETIMESTRING(first, 'mm/dd/yyyy'));

getField(fieldname2|n).setVal(GETDATETIMESTRING(last, 'mm/dd/yyyy'));

})()

There are other alternatives. For example, the following equation is equivalent to the previous one:

(function(){
let first = MONTH()+'/1/'+YEAR(),
last = MONTH()+'/'+DAY(EOMONTH(TODAY()))+'/'+YEAR();

getField(fieldname1|n).setVal(first);

getField(fieldname2|n).setVal(last);

})()

Best regards.

 

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