Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
555
IGDatePicker format issue
posted

 I want to show date in dd/mm/yyyy format but it always shows mm/dd/yyyy format. Also I want to set a default date to my control on page load

My view has:

<div class="col-md-4 col-sm-4 ">

@(Html.Infragistics().DatePicker()

.ID("TDate")

.ButtonType(TextEditorButtonType.DropDown)

.Render())

<input type="hidden" value="@ViewBag.TDate" id="hdnFlag" name="hdnFlag" />

</div>

My controller has :

public ActionResult Index()

{

ViewBag.TDate = "16-MAR-2017";

return View();

}

My javascript to set the default value is:

$(document).ready(function () {

var h1 = document.getElementById('hdnFlag');

if (h1 != null) {

h1 = h1.value.replace("-", " ");

h1 = h1.split("-").join(" ");

var twd = new Date(h1);

twd.toLocaleDateString("en-GB");

var d = twd.getDate();

var m = twd.getMonth();

var y = twd.getFullYear();

$("#TDate").igDatePicker({

value: new Date(y, m, d),

dateDisplayFormat: "dd/MM/yyyy",

minValue: new Date(y - 1, m, d)

})

}

});

I am not able to set the date correctly also if I change the date it shows in mm/dd/yyyy format.

Can anyone please help?

Regards

Singh

Parents Reply Children
No Data