下面是我用来在acrobat中进行数字签名和日期标注的代码。我需要的日期格式为YYYYMMDD
(即20180808
),但是我的代码没有显示两位数的月份或日期。我已经进行了研究以获取两位数的月份/日期,但是我发现的所有答案都不适用于我拥有的代码,我无法使其正常工作。任何帮助都会很棒。
// JavaScript code to add the date at signing time
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var signingTime = year +"/"+month+"/"+day
var f = this.getField("undefined");
f.value = signingTime;
var fieldsToLock = ["undefined"];
for (var i in fieldsToLock) this.getField(fieldsToLock[i]).readonly = true;
答案 0 :(得分:0)
稍后您必须自己写一个0
,如下所示:
var currentTime = new Date(),
month = currentTime.getMonth() + 1,
day = currentTime.getDate(),
year = currentTime.getFullYear();
day = day < 10 ? '0' + day : day;
month = month < 10 ? '0' + day : day;
var signingTime = year +"/"+month+"/"+day;
var f = this.getField("undefined");
f.value = signingTime;
var fieldsToLock = ["undefined"];
for (var i in fieldsToLock)
this.getField(fieldsToLock[i]).readonly = true;