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?
Copy link to clipboard
Copied
Number(util.printd("yymmdd", new Date())) + 101010
Copy link to clipboard
Copied
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());
}