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

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

Community Beginner ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

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

Views

1.0K

Translate

Translate

Report

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

correct answers 2 Correct answers

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();

Votes

Translate

Translate
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);

 

Votes

Translate

Translate
Community Expert ,
May 12, 2020 May 12, 2020

Copy link to clipboard

Copied

Replace the first line with this:

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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