Date Format in Syncfusion Datepicker Component

21 Feb 20241 minute to read

Date format is a way of representing the date value in different string format in textbox.

By default the DatePicker’s format is based on the culture. You can also set the own custom format by using the format property.

NOTE

Once the date format property has been defined, it will be common to all the cultures.

To know more about the date format standards, refer to the Internationalization Date Format section.

The following example demonstrates the DatePicker with the custom format (yyyy-MM-dd).

@Html.EJS().DatePicker("element").Value(ViewBag.value).Format("yyyy-MM-dd").Placeholder("Enter date").Render()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult DateRange()
        {
            ViewBag.value = new DateTime(DateTime.Now.Year,DateTime.Now.Month,14);
            return View();
        }
    }
}