How can I get it, the time from Razor ASP.NET

0

On this occasion I have a question which is, how can I get the time or the time from Razor or a way to get them separately, I attach my entity Cls and the View, thank you and excuse the inconvenience.

 using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ComponentModel.DataAnnotations;


    namespace model.entity
    {
       public class Cursos
        {
            private int _IdCursos;

            public int IdCursos
            {
                get { return _IdCursos; }
                set { _IdCursos = value; }
            }
            private string _Nombre;

            public string Nombre
            {
                get { return _Nombre; }
                set { _Nombre = value; }
            }
            private int _IdProfesor;

            public int IdProfesor
            {
                get { return _IdProfesor; }
                set { _IdProfesor = value; }
            }
           [DataType(DataType.Date)]
            private DateTime  _FechaInicio;

            public DateTime FechaInicio
            {
                get { return _FechaInicio; }
                set { _FechaInicio = value; }
            }
           [DataType(DataType.Date)]
            private DateTime _FechaFinal;

            public DateTime FechaFinal
            {
                get { return _FechaFinal; }
                set { _FechaFinal = value; }
            }
           [DataType(DataType.Date)]
            private DateTime _HoraInicio;       

            public DateTime HoraInicio
            {
                get { return _HoraInicio; }
                set { _HoraInicio = value; }
            }
           [DataType(DataType.Date)]
            private DateTime _HoraFinal;

            public DateTime HoraFinal
            {
                get { return _HoraFinal; }
                set { _HoraFinal = value; }
            }
            private string _Notas;

            public string Notas
            {
                get { return _Notas; }
                set { _Notas = value; }
            }
            public Cursos()
            { 
            }
            public void Curzos(int idCursos, string Nombre, int idProfesor, DateTime fechaInicio, DateTime fechaFin, DateTime horaInicio, DateTime horafinal, string _notas)
            {
                this._IdCursos = idCursos;
                this._Nombre = Nombre;
                this._IdProfesor = idProfesor;
                this._FechaInicio = fechaInicio;
                this._FechaFinal = fechaFin;
                this.HoraInicio = horaInicio;
                this.HoraFinal = horafinal;
                this.Notas = Notas;
            }

        }
    }
@model model.entity.Cursos

@{
    ViewBag.Title = "Eliminar";
    Layout = null;
}

<h2>Eliminar</h2>
@using (Html.BeginForm("Crear", "Curso", FormMethod.Post))
{ 
    <div>
         <div>
            <text> ID Cursos</text>
            @Html.TextBoxFor(model => model.IdCursos)
        </div>
        <div>
            <text> Nombre</text>
            @Html.TextBoxFor(model => model.Nombre)
        </div>
        <div>
            <text> Id Profesor </text>
            @Html.TextBoxFor(model => model.IdProfesor)
        </div>
        <div>
            <text>Fecha Inicio  </text>
            @Html.TextBoxFor(model => model.FechaInicio, "{0:dd/MM/yyyy}", new { @class = "form-control", @readonly = true })
        </div>
        <div>
           <text> Fecha Final </text>
            @Html.TextBoxFor(model => model.FechaFinal, "{0:dd/MM/yyyy}", new { @class = "form-control", @readonly = true })
        </div>
        <div>
            <text> Hora Inicio </text>
            @Html.TextBoxFor(model => model.HoraInicio)    
        </div>
        <div>
            <text> Hora Final </text>
            @Html.TextBoxFor(model => model.HoraFinal)
        </div>
        <div>
            <text> Notas </text>
            @Html.TextAreaFor(model => model.Notas)
        </div>
    </div>
    <div>
        <button type="submit">Eliminar</button>
        <a href="#" id="bus">Buscar</a>
    </div>
}
    
asked by Chuy Mogollan 26.12.2018 в 19:12
source

1 answer

0

In a block of code you can call the current date and time of the DateTime class

@{ string format = "dd/MM/yyyy HH:mm:ss"; var now = DateTime.Now.ToString(format); }

    
answered by 26.12.2018 в 20:11