I need current date if the system date in past.Because if iam changing system date past my datepicker is also changed to past date but i don't want to change datepicker to my system date.My datepicker should work on current date not on system date And my datepicker should not enable for pastdates
This is my date picker code:
var usTimeZoneVal = new Date().toLocaleString('en-US', { timeZone: 'America/New_York' });
$("#USdate").val(indianTimeZoneVal);
$('#datetimepicker2 , #datetimepicker3')
.datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy/mm/dd',
//startDate: '+0d'
startDate: usTimeZoneVal
})
.on('changeDate', function (e) {
$('#datetimepicker2').datepicker('hide');
$('#GuestSearchForm').bootstrapValidator('revalidateField', 'Servicedate');
});
And this is my Controller code:
public ActionResult GetServiceProviders(RankedServices.Entities.Admin.Services Services)
{
// if (Services != null && Services.SelectedServiceIds != null)
string ServiceDate = Services.Servicedate.ToString("MM/dd/yyyy");/*Start Added by Arun 13-April-2017*/
DateTime USDates = Convert.ToDateTime(Services.USdate);
string USDate = USDates.ToString("MM/dd/yyyy");
int FutureDate = DateTime.Compare(Convert.ToDateTime(ServiceDate), Convert.ToDateTime(USDate));/* End*/
if (Services != null && (Services.SelectedServiceIds != null || Services.ServiceIds != null) && FutureDate >= 0)
{
if (Services.SelectedServiceIds != null)
Services.ServiceIds = string.Join(",", Services.SelectedServiceIds);
// Services.ServiceIds = string.Join(",", Services.SelectedServiceIds);zz
if (Services.ServiceIds != "" && (Services.SubLocationID != "" || Services.Servicedate.Date != null))
{
string UserID = "";
if (Session["UserID"] != null)
{
UserID = Session["UserID"].ToString();
}
Services.lstServiceProviders = ServiceDetails.GetServiceProviders(Services.SubLocationID, Services.ServiceIds.TrimEnd(','), UserID, ServiceDate, Services.Daymode, Services.ProviderID);
IEnumerable<RankedServices.Entities.Admin.Services> lstServices = ServiceDetails.GetServicesList(Services.SubLocationID.ToString());
ViewBag.SelectedServices = new MultiSelectList(lstServices, Services.SelectedServiceIds);
return View("ServicesList", Services);
// return Json(lst, JsonRequestBehavior.AllowGet);
}
else
{
return RedirectToAction("guestsearch", "Home");
}
}
else
{
return RedirectToAction("guestsearch", "Home"); // if none are selected re-direct to Guest-Search
}
}