'how can i pass value from controller to datepicker?

I am passing a value date from a controller 'Edit' to an input css datepicker however it is not displaying the value instead it displays mm/dd/yyyy. I've tried several options such as tag helper 'asp-for', 'viewbag' ,'viewdata' and 'tempdata' unfortunately doesn't change.

enter image description here

//Controller

public IActionResult EditCedant(int CedantId)
        {
            if(CedantId == null || CedantId == 0)
            {
                return NotFound();
            }
            var cedantsfromDb = _db.dbo_life.Find(CedantId);
           
            if(cedantsfromDb == null)
            {
                return NotFound();
            }
            ViewBag.DOB = cedantsfromDb.DateofBirth;
            
            return PartialView("_partialEditView", cedantsfromDb);
        }
        
        
[![enter image description here][1]][1]//View Input
   
    <input type="date" class="form-control" id="datepicker1" date-provide="datepicker" [email protected]/>


Solution 1:[1]

Did you try to put the date format in tag helper? Instead of passing the DateTime value in the ViewBag, try getting the value from the model:

@Html.TextBox("my-input-date", Model.DateofBirth, "{0:yyyy-MM-dd}", new { type="date" })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sycamore55