Page 1 of 1

getFullYear() error

Posted: Wed Feb 08, 2023 6:30 pm
by treed
While attempting to run a slightly modified version of the sample code from https://github.com/nuBuilder/nuBuilder- ... _date_time

Code: Select all

function getCurrentDate() {
    var d = new Date();
    var df = nuPad2(d.getMonth() + 1) + '/' + nuPad2(d.getDate() + '/' + d.getFullYear());
    return df;
}
I get the following error in the console.
nucommon.js?ts=20230208091545:2832 Uncaught TypeError: d.getFullYear is not a function
at nuSetDateValue (nucommon.js?ts=20230208091545:2832:13)
at reportCreated (index.php:25:2)
at xhr.onreadystatechange (nuajax.js?ts=20230208091545:227:7)

Any ideas? I get the same error with just a cut and paste from the example too.

Re: getFullYear() error

Posted: Wed Feb 08, 2023 6:39 pm
by kev1n
You can use nuBuilder's inbuilt nuCurrentDate() function and pass a format:

Code: Select all

nuCurrentDate('mm/dd/yyyy')
I'm not seeing any errors when I run your modified function in the developer console,
dev.png

Re: getFullYear() error

Posted: Wed Feb 08, 2023 7:32 pm
by treed
Ah, it was not that function generating the error, it was this line

Code: Select all

nuSetDateValue('OrdPaid',nuCurrentDate('mm/dd/yyyy'));
So how do I get the value into a date field on the current form???

Re: getFullYear() error

Posted: Wed Feb 08, 2023 8:19 pm
by kev1n
Like this?

Code: Select all

nuSetDateValue('OrdPaid');

Re: getFullYear() error

Posted: Wed Feb 08, 2023 8:51 pm
by treed
That was to easy! Thanks again.