.NET Fiddle

CSharp · Mvc

Model

using System;
using System.ComponentModel.DataAnnotations;

namespace HelloWorldMvcApp
{
	public class SampleViewModel
	{
		
		
    [Required]
    [DataType(DataType.Date)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
    public DateTime DataInicialContrato { get; set; }

  
    [Required]
    [DataType(DataType.Date)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:yyyy-MM-dd}")]
    public DateTime DataFinalContato { get; set; }  
	}
}

View

@model HelloWorldMvcApp.SampleViewModel
@{
	Layout = null;
}

<!DOCTYPE html>
<!-- template from http://getbootstrap.com/getting-started -->

<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Bootstrap 101 Template</title>
	</head>
	
	<body>
		<div class="form-group">

            <div class="col-md-3 col-sm-12">
                @Html.LabelFor(model => model.DataInicialContrato , htmlAttributes: new { @class = "control-label", @for = "datainicialcontrato" })
                @Html.EditorFor(model => model.DataInicialContrato, new { htmlAttributes = new { @class = "form-control ", @id = "datainicialcontrato"  } })
                <span class="help-block">@Html.ValidationMessageFor(model => model.DataInicialContrato, "", new { @class = "text-danger" })</span>
            </div>

            <div class="col-md-3 col-sm-12">
                @Html.LabelFor(model => model.DataFinalContato , htmlAttributes: new { @class = "control-label", @for = "datafinalcontrato" })
                @Html.EditorFor(model => model.DataFinalContato, new { htmlAttributes = new { @class = "form-control", @id = "datafinalcontrato" } })
                <span class="help-block">@Html.ValidationMessageFor(model => model.DataFinalContato, "", new { @class = "text-danger" })</span>
            </div>

 </div>

	</body>
</html>

Controller

using System;
using System.Web.Mvc;
using System.Collections.Generic;

namespace HelloWorldMvcApp
{
	public class HomeController : Controller
	{
		[HttpGet]
		public ActionResult Index()
		{
			return View(new SampleViewModel());
		}


	}
}
;