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

Date conversion

New Here ,
Feb 06, 2024 Feb 06, 2024

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
396
Translate
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

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

Translate
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
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

Translate
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