Page 1 of 1
The time in a subform
Posted: Tue Aug 01, 2023 1:50 am
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.
Re: The time in a subform
Posted: Sun Aug 06, 2023 10:58 am
by kev1n
Hi,
How are you currently retrieving the value? To better assist you, could you please share some code that demonstrates your approach?
Re: The time in a subform
Posted: Sun Aug 06, 2023 5:39 pm
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
Re: The time in a subform
Posted: Mon Aug 07, 2023 7:23 am
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?
Re: The time in a subform
Posted: Mon Aug 07, 2023 12:15 pm
by cuadradoja
Hi Kev1n...It's Datetime-local.
Re: The time in a subform
Posted: Mon Aug 07, 2023 12:26 pm
by kev1n
Untested:
Code: Select all
const now = new Date();
const formattedDate = now.toISOString().slice(0, 16);
nuSetValue(this.id, formattedDate);
Re: The time in a subform
Posted: Mon Aug 07, 2023 4:20 pm
by cuadradoja
It didn't work... anyway, thank you very much for your advice!!!
Re: The time in a subform
Posted: Mon Aug 07, 2023 4:30 pm
by kev1n
There was a typo: ormattedDate -> formattedDate
Re: The time in a subform
Posted: Sun Aug 27, 2023 4:46 pm
by cuadradoja
Hi kev1n, you're great!!!! Thanks a lot....