Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
140987 | Nov 17,2018 07:48 AM UTC | Nov 23,2018 12:17 PM UTC | ASP.NET MVC | 8 |
![]() |
Tags: DatePicker |
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.EJ().DatePickerFor(model => model.Value).Width("50%").Locale("hr-HR").TimeZone(false)
@Html.ValidationMessageFor(model => model.Value)
@Html.EJ().Button("btn").Size(ButtonSize.Small).Text("Post").Type(ButtonType.Submit)
} |
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.EJ().DateTimePickerFor(model => model.objectValue).Width("50%").Locale("hr-HR").ClientSideEvents(e => e.Create("onCreate"))
@Html.ValidationMessageFor(model => model.objectValue)
@Html.EJ().Button("btn").Size(ButtonSize.Small).Text("Post").Type(ButtonType.Submit)
}
<script>
function onCreate(args) {
var jan = new Date(new Date(this._options.value).getFullYear(), 0, 1);
var jul = new Date(new Date(this._options.value).getFullYear(), 6, 1);
//checking the difference between timezone offset of current timezone with the DST time.
if (new Date(this._options.value).getTimezoneOffset() - Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()) == 0) {
// if the timezone offset is -60, then 1 hour will added to the date value
updatedValue = new Date(this._options.value).setHours(new Date(this._options.value).getHours() + 1);
this.option("value", new Date(updatedValue));
}
}
</script> |
@model ej1mvc.Controllers.DateTimePickerModel
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.EJ().DateTimePickerFor(model => model.Value).Width("50%").Locale("hr-HR").ClientSideEvents(e => e.Create("onCreate"))
@Html.ValidationMessageFor(model => model.Value)
@Html.EJ().Button("btn").Size(ButtonSize.Small).Text("Post").Type(ButtonType.Submit)
}
<script>
function onCreate(e) {
if (new Date(e.model.value).getFullYear() < 1983) {
this.model.value = new Date(new Date(e.model.value).getTime() - (new Date(e.model.value).getTimezoneOffset() * 60 * 1000));
this._updateDateTime();
}
}
</script> |
protected void Application_BeginRequest(Object sender, EventArgs e)
{
CultureInfo.CurrentCulture = new CultureInfo("hr-HR");
CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
newCulture.DateTimeFormat.ShortDatePattern = "dd.MM.yyyy.";
newCulture.DateTimeFormat.DateSeparator = ".";
System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
} |
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.