Copy link to clipboard
Copied
how can i get my output and created date to look like my Modified date? The below is how it looks in the script now. I just like the look of the Modification date string. If its not possible to make them look that way no big deal I'm just curious.
Date Modified: June 7, 2016 3:52 PM
Date Output: 06/06/16
Date Created: 06/06/16
The above script function is to get custom format string from Date object.
Another easy option is:
In order to change format of Modification Date variable you can do below:
Via Script
var md = doc.textVariables.itemByName("Modification Date");
md.variableOptions.format = "MMMM dd, yyyy hh:mm a";
Via UI
Go to Type->Text Variables -> Define
Select Modification Date and click Edit button.
In the Date Format, enter the following:
MMMM dd, yyyy hh:mm a
Now, all text variable instances of Modification Date will
...Copy link to clipboard
Copied
This is the code i'm using the R5 and 6 are exactly the same other than the different Cell Numbers.
var cell3OfColumn2insertionPoint1 = myTable.columns[1].cells[3].insertionPoints[0];
var R4 = cell3OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell3OfColumn2insertionPoint1);
R4.associatedTextVariable = doc.textVariables.itemByName("Modification Date");
R5.associatedTextVariable = doc.textVariables.itemByName("Output Date");
R6.associatedTextVariable = doc.textVariables.itemByName("Creation Date");
Copy link to clipboard
Copied
You can use the Date class to get what you want but please note the following:
var date = new Date();
date.toDateString: Wed Jun 08 2016
date.toLocaleDateString: Wednesday, June 08 2016
date.toLocaleString: Wednesday, June 08 2016 08:25:58
date.toGMTString: Wednesday, 08 Jun 2016 02:55:58 GMT
date.toLocaleTimeString: 08:25:58
date.toTimeString: 08:25:58 GMT+0530
date.toUTCString: Wednesday, 08 Jun 2016 02:55:58 GMT
date.toString: Wed Jun 08 2016 08:25:58 GMT+0530
date.getDate(): 8 (1 - 31)
date.getMonth(): 5 (0-11)
date.getFullYear(): 2016
date.getTime(): 1465354558248
You should choose between whether you want local or UTC/GMT time.
Your function should look like:
function getFormattedDateString() {
var date = new Date();
var month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"];
// Handle zero prefix
var formatDate = ("0" + date.getDate()).substr(-2);
var formatHour = ("0" + date.getHours()).substr(-2);
var formatMin = ("0" + date.getMinutes()).substr(-2);
var formatSec = ("0" + date.getSeconds()).substr(-2);
// Handle AM/PM time period
var period = (date.getHours() < 12)?"AM":"PM";
return month[date.getMonth()] +" " + formatDate + ", " + date.getFullYear() + " " + formatHour + ":" + formatMin + " " + period;
}
Copy link to clipboard
Copied
The above script function is to get custom format string from Date object.
Another easy option is:
In order to change format of Modification Date variable you can do below:
Via Script
var md = doc.textVariables.itemByName("Modification Date");
md.variableOptions.format = "MMMM dd, yyyy hh:mm a";
Via UI
Go to Type->Text Variables -> Define
Select Modification Date and click Edit button.
In the Date Format, enter the following:
MMMM dd, yyyy hh:mm a
Now, all text variable instances of Modification Date will have your desired format.
Copy link to clipboard
Copied
Both these are correct i wish i could mark correct for both.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now