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!
Replace the first line with this:
var d = new Date();
d.setDate(d.getDate()-1);
event.value = d.toString();
I would go further, don't use AFDate_FormatEx
Just set it directly:
event.value = util.printd("h:MM tt, mm/dd/yyyy",d);
Copy link to clipboard
Copied
Replace the first line with this:
var d = new Date();
d.setDate(d.getDate()-1);
event.value = d.toString();
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!
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);
Copy link to clipboard
Copied
This works perfectly! Thank you kindly for your help!!