Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

getFullYear() error Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

getFullYear() error

Unread post 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.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: getFullYear() error

Unread post 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
You do not have the required permissions to view the files attached to this post.
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: getFullYear() error

Unread post 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???
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: getFullYear() error

Unread post by kev1n »

Like this?

Code: Select all

nuSetDateValue('OrdPaid');
treed
Posts: 205
Joined: Mon May 18, 2020 12:02 am
Been thanked: 2 times
Contact:

Re: getFullYear() error

Unread post by treed »

That was to easy! Thanks again.
Post Reply