简体   繁体   中英

Blazor Serverside Application Datetime default to 01/01/0001

I tried to make my CreatedDate column to be null or at least show the current date when I launch the application instead of 01/01/0001. I tried the example in Format MVC default Date (01/01/0001) to be empty and by adding a dot notation "newPerson.StartDate.Now" to the column on the razor page which wasn't working either.

public DateTime? MyDate { get; set; }

In your constructor of your object:

MyDate = null;

Or if you want to use a date

MyDate = DateTime.Now;

I just tested and both work for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM