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

Date conversion

New Here ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

I want to convert the date YYMMDD,  240206 to a number then add 10 to each of the year month and day.

So 341216.

 

Any advice as to where I can find a resource for this?

TOPICS
PDF forms

Views

99

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 ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

Number(util.printd("yymmdd", new Date())) + 101010

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 ,
Feb 06, 2024 Feb 06, 2024

Copy link to clipboard

Copied

LATEST

There is no such date format. I think you mean "yymmdd".  

There are several ways to manipulate dates. There's the Acrobat JavaScript date functions util.scand() and util.printd(). Then there are the Core JS Date functions. 

 

But for your case the easiest method is just to split the string into 3 two digit sections and convert them to numbers.  There are also several ways to do this. I'd use a regular expression.

 

if(/^(\d{2})(\d{2})(\d{2})$/.test(strDateText))

{

      strRslt = (Number(RegExp.$1) + 10).toString()) + 

                     (Number(RegExp.$2) + 10).toString()) + 

                     (Number(RegExp.$3) + 10).toString());

}

 

 

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