Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need calculation script for using Yesterday's Date in a Dynamic Stamp

Community Beginner ,
May 12, 2020 May 12, 2020

Hello all, this is my first post here!

 

My team wants a dynamic stamp that shows yesterday's date from whatever date the stamp is placed. I have scoured this community and multiple websites for this script and have found nothing. Please know that I know next to nothing about Javascript.

 

What is the script I need to use to calculate today's date -1?

 

Can this script for today be edited to subtract one day?

event.value = (new Date()).toString();

AFDate_FormatEx("h:MM tt, mm/dd/yyyy");

 

Thank you very much for your help!

 

 

TOPICS
How to , PDF forms
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
May 12, 2020 May 12, 2020

Replace the first line with this:

var d = new Date();
d.setDate(d.getDate()-1);
event.value = d.toString();

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2020 May 12, 2020

I would go further, don't use AFDate_FormatEx

 

Just set it directly:

event.value = util.printd("h:MM tt, mm/dd/yyyy",d);

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2020 May 12, 2020

Replace the first line with this:

var d = new Date();
d.setDate(d.getDate()-1);
event.value = d.toString();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2020 May 20, 2020

Using this with   AFDate_FormatEx("h:MM tt, mm/dd/yyyy");   gives me today's date. I've tried it several ways but it never returns yesterday's date. HOWEVER, using it with   event.value = util.printd("h:MM tt, mm/dd/yyyy",d);   as Thom_Parker says below does return yesterday's date correctly.

 

Thank you kindly for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2020 May 12, 2020

I would go further, don't use AFDate_FormatEx

 

Just set it directly:

event.value = util.printd("h:MM tt, mm/dd/yyyy",d);

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2020 May 20, 2020
LATEST

This works perfectly! Thank you kindly for your help!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines