시스템 날짜가 과거 인 경우 현재 날짜가 필요합니다. 시스템 날짜가 내 datePicker를 지나서 변경 될 때도 과거 날짜로 변경되지만 datepicker를 변경하지 않으려 고합니다. 내 시스템에 date.My의 날짜 선택기가없는 시스템 날짜에 현재 날짜에 작업을해야 그리고 내 날짜 선택기는 pastdates시스템 날짜를 과거로 변경하면 현재 날짜를 얻는 방법
을 위해 사용하지해야이 내 날짜 선택 코드 :
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');
});
그리고 이것은 내 컨트롤러 코드 :
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
}
}
는 [은 TimeServer] 질문 (http://stackoverflow.com/questions/1193955/how-to- query-an-ntp-server-using-c) – TaW