11.0: DateFormat

Change the Format of DateTimeOffset

In this section, we change the format of DateTimeOffset to trim off some of the fat and make it easier to read.

  1. Go to ElevenNote.Web -> Views -> Shared

  2. Create a new folder called DisplayTemplates

  3. MVC will look for this folder to override the default format

  4. Right click on the DisplayTemplates folder and click Add -> View

  5. Fill it out like this, the View name should match the Data Type that we are using:

    DateTime View

  6. Delete everything in the file and replace with this:

     @model System.DateTimeOffset?
    
     <span>
         @(Model.HasValue ? Model.Value.LocalDateTime.ToString("G") : "-")
     </span>
  7. G is the specific format we have chosen, here is a list of other options.

  8. Your view should look like this:

    DateTime View

    G is for General date/time pattern (long time)

  9. Git

Next, we'll add the option to star a note.

Last updated