javascript - CalendarExtender saying the wrong date is selected, possibly timezone related -


i have page textbox , calendarextender supposed allow me detect date selected. however, reporting date isn't selected.

<asp:textbox id="tbeffectivedate" runat="server"     cssclass="input-small"     maxlength="10"     text='<%# bind("neweffectivedate", "{0:mm/dd/yyyy}") %>'> </asp:textbox> <ajaxtoolkit:calendarextender id="atkeffectivedate" runat="server"     firstdayofweek="sunday"     targetcontrolid="tbeffectivedate"     format="mm/dd/yyyy"     onclientdateselectionchanged="checkforsunday"> </ajaxtoolkit:calendarextender> 

essentially i'm making sure user has selected sunday, when select day on calendar, javascript says day before. i'm perplexed.

function checkforsunday(sender, args) {     var selecteddate = new date();     selecteddate = sender.get_selecteddate();     // both of these show date before date selected     alert(sender.get_selecteddate());      if (selecteddate.getday() != 0) {         // not sunday         var sunday = selecteddate;         // calculated nearest sunday         sunday.setdate(selecteddate.getdate() - selecteddate.getday());         sender.set_selecteddate(sunday);         // tell user date wasn't sunday         // , previous sunday selected.         $("#must-be-sunday").modal("show");     } } 

for example, if select sunday, such may 5th:

enter image description here

then @ line alert(sender.get_selecteddate());, displays

enter image description here

this saying saturday, may 4th selected instead of may 5th. since in locale, -0700 , displaying 7 hours before midnight on 5th, i'm guessing has timezone.

does know may causing , how fix doesn't work time , date selected?

you right problem due timezones calendarextender use utc dates each day cell value. if want check day of week selected may use date.getutcday() function instead of date.getday() , getutcdate() instead of getdate() in onclientdateselectionchanged handler.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -