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

Date conversion

New Here ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

在JavaScript中,我使用var formattedDate = util.printd("mm/dd/yyyy", currentDate);输出日期,但出现错误,指出格式不正确,需要我使用var formattedDate = util.printd("dd mmmm yyyy “, 当前日期);但是即使修改之后,错误仍然无法解决。

console.println("Calculating date for Today field.");
try {
var f = this.getField("Today");
if (f) {
// 获取当前日期
var currentDate = new Date();console.println(currentDate);
// 使用 "dd mmmm yyyy" 格式化日期
var formattedDate = util.printd("mm/dd/yyyy",currentDate);
f.value = formattedDate;
console.println("Date set to: " + f.value);
} else {
console.println("Field 'Today' not found.");
}
} catch (e) {
console.println("Error: " + e.message);
}
//</ACRO_script>
//</AcroForm>

 

 

 

yujie38056535y5v2_1-1718412951035.pngyujie38056535y5v2_2-1718412967021.png

 

TOPICS
JavaScript , PDF

Views

118

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 1 Correct answer

Community Expert , Jun 14, 2024 Jun 14, 2024

You have lots of JavaScript there that seems needless and redundant.  What exactly are you trying to accomplish?  To output the current date in the format of "mm/dd/yyyy" all you have to do is this:

util.printd("mm/dd/yyyy", new Date());

The second input parameter in util.printd is a date object, not a formatted date.

Votes

Translate

Translate
New Here ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

In JavaScript, I am using var formattedDate = util.printd("mm/dd/yyyy", currentDate); to output the date, but I am getting an error stating that the format is incorrect and requiring me to use var formattedDate = util.printd("dd mmmm yyyy", currentDate);. However, even after modifying it, the error still cannot be resolved.

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 ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

LATEST

You have lots of JavaScript there that seems needless and redundant.  What exactly are you trying to accomplish?  To output the current date in the format of "mm/dd/yyyy" all you have to do is this:

util.printd("mm/dd/yyyy", new Date());

The second input parameter in util.printd is a date object, not a formatted date.

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