I’ve seen a strange situation. See the following coding:
var _time = new Date(registration_time_start)
_time.setFullYear(registration_date.getFullYear())
_time.setMonth(registration_date.getMonth())
_time.setDate(registration_date.getDate() + 1)
_time.setMilliseconds(0);
registration_time_start = _time;
I have 2 fields; 1 field for date registration (registration_date, with format DD/MM/YYYY) and 1 field for time registration (registration_time_start, with format HH:mm)
My field registration_date contains 30/07/2009
My field registration_time_start contains initially 01/01/1970 08:00 (because I use format HH:mm Servoy defaults the date to 01/01/1970)
So far, so good
The above coding shows that I take the dateparts of registration_date and put this in the datepart of registration_time_start
What I don’t understand is that I have to use:
_time.setDate(registration_date.getDate() + 1)
instead of
_time.setDate(registration_date.getDate())
Is there an explanation for that? If I use _time.setDate(registration_date.getDate()) the datepart in registration_time_start contains 29/07/2009
It doesn’t seem very logic to me, that when I put a getDate() into a setDate() that I have to add 1 day.
Joas:
I’m not sure what causes your problem. Are both values saved correctly to the db?
They are saved in the database as you see them in debugger. So as 29/07/2009 without the +1 and as 30/07/2009 with the +1
Joas:
On a side note, why do you use two values anyway? Why don’t you put the same field on the form, once with format DD/MM/yyyy and once with HH:mm?
Because it is a time registration system where 1 date is selected; A starting date; ending date and probably also start/end of pause;
So I don’t want the date to be repeated in each time field