I have put a date field into my gravity forms on my website. I want to populate the date field but with a date 14days after sending the form. How do I do this please? I have the date field and form ID. I am able to put snippet or code in Theme Functions but do not know what code to put in? Really could do with some advice or exact code to put in and where in the Theme Functions.php or any other advice? Thanks And Appreciated in advance. . .
What i am trying to do is populate the date on a specific field using a specific form and a specific date field ID. To populate date but adding 14days. And so it can not be changed for instance it is purchasing a homecare contract that starts 14days after the date when submitted. So date +14 after form submission. TY.
After having added the code above to your site, you can dynamically populate a field with the +14 day value by clicking the field setting Advanced → Allow field to be populated dynamically and then entering Parameter Name // date_plus_fourteen.
I have done the code etc but the date is sent on my form ad mm-dd-yyyy allthough the actual field and form is showing dd-mm-yyyy it is just the sent email to myself and my customer? How do I amend so it populates dd-mm-yyyy? Thanks well in advance?
I would like to try again for advice. Here is a screenshot of the issue. It populates but want to change the date format. When It populates in the UK date format. Using the code below works except it populates the wrong days and months if I change to DD-MM-YY. So I am getting there but not quite there.
Also is there a code or snippet I can use once populated that the date can not be amended by the user signing up for plan I offer?
Really would like to get this resolved. Really happy if anyone can assist. Thanks again though 100% for the help to date as would not have this populated otherwise. I am in UK and have a UK site. Regards. . .
Maybe you could use this free plugin by Gravity Wiz to format your date display? I haven’t tried it myself but it would be great if it could work for you.
I haven’t tried this myself with the function under discussion, but I use the strtotime function and I know it can be adapted to return different date and time formats. You might want to look at this site: PHP: Date Formats - Manual.
The “m/d/Y” portion of the function tells the function to return a date in the American format of mm/dd/yyyy. Replace it with the format you want, using the appropriate date/time format. I think you might want “d-m-Y”.
Looks like you’re almost across the finish line here, Andrew, but if you need to do this again or anything more complicated, use our free Populate Dates snippet. It’ll handling formatting the value to that of the Date field you’re populating. It can even populate/modify dates based on the values of other fields.