<" /> <" /> <"/>

mvc how to display datetime in date format

982 Views Asked by At

In Mvc how to display DateTime in Date Format Like 1/1/2015 12:00:00 AM, This Date Format I Wana to show 1/1/2015

<table id="table_id">

    <thead>
        <tr>
            <td>EmpId</td>
</tr>
    <tbody>

     @foreach (var ee in Model.GetEmployeeFromHybridge)
            { <td>@ee.date</td>}
    </tbody>
  $(document).ready(function () {
        $('#table_id').dataTable();

    })
1

There are 1 best solutions below

0
Alex Stephens On

You can just format a dateTime with .ToString("dd/MM/yyyy");

Be sure your field type is DateTime.

Here's a link showing way to format date and time. https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings