InputDate Formatting

Use the InputDate's format property to format and parse date values to suit your app.

The syntax of the format parameter is similar to the one used in .NET and is documented here.






1
2
3
4
5
6
7
8
// This file locates: "Scripts/Lesson/C1Input/InputDateFormatting.js".
c1.documentReady(function () {
    var formats = 'd|D|M|d/M/yy|MMMM dd, yyyy'.split('|');
    for (var i = 0; i < formats.length; i++) {
        var theDate = wijmo.Control.getControl('#theInputDateF' + i);
        theDate.format = formats[i];
    }
});
1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1InputController : Controller
    {
        // GET: InputDateFormatting
        public ActionResult InputDateFormatting()
        {
            return View();
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<h1>
    @Html.Raw(Resources.C1Input.InputDateFormatting_Title)
</h1>
 
<p>
    @Html.Raw(Resources.C1Input.InputDateFormatting_Text1)
</p>
<p>
    @Html.Raw(Resources.C1Input.InputDateFormatting_Text2)
</p>
<div id="inputDates" class="demo-settings">
    @{
        var formats = new[] { "d", "D", "M", "d/M/yy", "MMMM dd, yyyy" };
    }
    @for(var i = 0; i < formats.Length; i++)
    {
        var fmt = formats[i];
        var id = "theInputDateF" + i;
        <label for="@id">@fmt: </label>
        @Html.C1().InputDate().Id(id)
        <br />
    }
</div>