Mark Tabor

Mark Tabor

  • 586
  • 2k
  • 464.6k

How to set Datetime as current date time in MVC

Oct 1 2017 5:59 AM
I have a class as 
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace AdminLteMvc.Models
{
using System;
using System.Collections.Generic;
public partial class Designation
{
public Designation()
{
Date_Created = DateTime.Now;
Date_Modifed = DateTime.Now;
}
}
public int Design_Id { get; set; }
public string Design_Name { get; set; }
public Nullable<bool> IsActive { get; set; }
 public Nullable<DateTime> Date_Created { get ; set ; }
public Nullable<DateTime> Date_Modifed { get ; set ; }
}
}
I want to set datetime as current datetime instead of taking them from users i have also write a constructor and initilizing them in that but still null they are nullable in db as well

Answers (2)