Catalog client script - How to set the time of a Date/Time variable

KoenHaemels
Tera Contributor

Hi

I'm trying to set the time of a date/time variable in a catalog client script.
However, the date gets changed and set. But the time remains on 00:00:00.

var dateNumber = getDateFromFormat(g_form.getValue('temp1'), g_user_date_format);
var date = new Date(dateNumber);

// Initialize a new Date object
var newDateTime = new Date(date.getFullYear(), date.getMonth(), date.getDate());

// Set the time to 23:59:59
newDateTime.setHours(23);
newDateTime.setMinutes(59);
newDateTime.setSeconds(59);

// Set the value in the datetimeField
g_form.setDisplayValue('temp2', newDateTime);


Temp1 is a date variable and temp2 is a date/time variable.
The script gets the date that is selected in temp1 and puts it in temp2 and should add the time 23:59:59.
However the date is set but the time is not.

Regards

15 REPLIES 15

KoenHaemels
Tera Contributor

I also tried your setup and created an extra alert.
However this value is null?