Welcome to the nuBuilder Forums!

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

The time in a subform

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

The time in a subform

Unread post by cuadradoja »

Hi again...

I need to know how I can capture the current time in a field of a subform with the onchange event in the scripting. I can manage to do it with a particular date, but when I try with the time, it only displays 00:00.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: The time in a subform

Unread post by kev1n »

Hi,

How are you currently retrieving the value? To better assist you, could you please share some code that demonstrates your approach?
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Re: The time in a subform

Unread post by cuadradoja »

Hi Kevin, how are you doing?

I have a subform with a field called 'hora' and in it I put the following code:
Image1.png
Then the field only shows the date but without the current time, as seen in the following image:
Image2.png
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: The time in a subform

Unread post by kev1n »

nuSetDateValue() is used to update the value of a specified object with a date (excluding the time component) in a specific format.
What format is used for "Hora" - Is it text or Datetime-local?
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Re: The time in a subform

Unread post by cuadradoja »

Hi Kev1n...It's Datetime-local.
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: The time in a subform

Unread post by kev1n »

Untested:

Code: Select all

const now = new Date();
const formattedDate = now.toISOString().slice(0, 16);
nuSetValue(this.id, formattedDate);
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Re: The time in a subform

Unread post by cuadradoja »

It didn't work... anyway, thank you very much for your advice!!!
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: The time in a subform

Unread post by kev1n »

There was a typo: ormattedDate -> formattedDate
cuadradoja
Posts: 27
Joined: Thu Sep 01, 2022 3:42 am
Has thanked: 1 time

Re: The time in a subform

Unread post by cuadradoja »

Hi kev1n, you're great!!!! Thanks a lot....
Post Reply