title: Formatting DateTime in .NET Core React app
body: <p>I am new to .NET Core and am exploring creating applications with a React frontend and .NET back end. I am starting very simple and at the moment am just trying to format the DateTime. The relevant files are: </p>
  
  <p>DateController.cs:</p>
  
  <pre><code> public class DateController : Controller
      {
          [HttpGet, Route("GetDate")]
          public async Task&lt;string&gt; GetDate()
          {
              DateTime dt = DateTime.Now;
              string format = "MMM ddd d HH:mm yyyy"; 
              string info = $"Today is {dt.ToString(format)}";
              return info; 
          }
      }
  </code></pre>
  
  <p>Date.js:</p>
  
  <pre><code>
  import React, { Component } from "react";
  
  export class Date extends Component {
    constructor(props) {
      super(props);
      this.state = { date: "" };
  
      fetch("api/Date/GetDate")
        .then(response =&gt; response.text())
        .then(data =&gt; {
          this.setState({ date: data });
        });
    }
  
    render() {
      return &lt;h1&gt;{this.state.date} &lt;/h1&gt;;
    }
  }
  </code></pre>
  
  <p>However, the date doesn't seem to be formatted as I am expecting, as it displays in the browser like this (and even misses the "Today is..." part: </p>
  
  <p>"Sun Aug 18 2019 21:30:24 GMT+0100 (British Summer Time)". </p>
  
  <p>Can anyone please guide me as to where I have gone wrong?</p>
  
  <p>Thank you! </p>