Today's date on the pdf

Divi Forms
24 January, 2020 08:01:52
ionutsabo
Topics: 3
Messages: 8
Hi guys,

So I want to print the current date as dd.mm.yyyy on the pdf and I'm using the code below in the template.



var dt = new Date();
document.getElementById("datetime").innerHTML = (("0"+dt.getDate()).slice(-2)) +"."+ (("0"+(dt.getMonth()+1)).slice(-2)) +"."+ (dt.getFullYear());


The code has worked flawlessly for a couple of months, but lately, it's not updating the date and I'm getting pdfs with an older date that doesn't update.

Any solutions to this?

Thanks again for a great plugin!
24 January, 2020 08:17:35
E2Pdf
Support
Topics: 7
Messages: 3345
Hi,

Are you using this code on form? If so, PDF will output exactly date that was saved while submitting form. To output today dates to PDFs that can be generated in different time you must be able to use shortcode inside template directly:

[e2pdf-format-date format="d.m.yy"]now[/e2pdf-format-date]

We remain at your service.


We would really appreciate your feedback at WordPress.org!
24 January, 2020 08:29:45
ionutsabo
Topics: 3
Messages: 8
"Are you using this code on form?
If so, PDF will output exactly date that was saved while submitting form."

Yes, that's actually what I wanted to say. Sorry for the confusion.
So I'm using the code from my initial message, but, for some reason, for example, today it would print some previous date on the pdf that I send to the client submitting the form, using the [e2pdf-attachment id="2"] shortcode (2 being the id of my Divi form).

if I, for example, go to the template edit, and edit the field that holds this code, but don't really change anything, it will start again showing the correct date. But that's only until the next day when it will print previous date.

I don't really understand why this is happening, but... yeah... I can do the trick with "editing the template" everyday. Not ideal, but it works for me. i do get daily submissions and this date is important on the pdf.


Thanks again
24 January, 2020 08:48:11
E2Pdf
Support
Topics: 7
Messages: 3345
It looks like issue with javascript / cache / autofill.

Can you check please:

1) If you will include output date field directly to email, will it generate same old date as inside PDF? As it looks not E2Pdf issue as it works with pre-filled fields.

2) You can also try to fill out form in "Private" tab, for example, to see if issue will remain.

We remain at your service.
We would really appreciate your feedback at WordPress.org!
24 January, 2020 08:52:28
ionutsabo
Topics: 3
Messages: 8
Will check on that later today.

I'll probably start using a different form builder, as Divi's is not the most versatile.

Thanks, again!
PS: You may close the topic.