Closed gregh3269 closed 7 years ago
I'm not sure this is even remotely possible. Javascript wants to pull the system time when you just call new Date(). To do something like this, I'd have to override how the Date object is created, in every single instance in DateBox - and there are a lot of them. Also, I'm not sure how you'd go about supplying the date/time to the client - if you are working with time, your supplied time is wrong in as little as 59 minutes, if you are working with date, your supplied date is wrong in as little as 23 hours :)
I did briefly look at if there was a NTP implementation on JavaScript, and there is, sort of. It's an imperfect solution to be sure, it can't alter the system date, and it seems like a lot of trouble.
I suppose you could send the server date to the client, set the defaultValue to the servers "today", and then do the math to figure what the min/maxDays offset is from the clients today. At a glance:
offset = serverTime - clientTime;
maxDays = yourConstant + offset;
minDays = yourConstant + offset;
or something along these lines. Pseudo code of course.
OK thanks, will see if I can use this calculation. In the meantime I guess I should do a bit more server side validation. The combination should stop any of these erroneous dates hitting the db.
Cheers Greg
Hello, If my mobile has the wrong date/time, and then I limit using minDays/maxDays it pops at the wrong place and won't let my actual date be picked. Is there an initialisation option to set what datebox thinks is its internal todays date? I have tried defaultValue but it seems it is the picker date rather than the internal todays date.
Cheers Greg