title: Convert Unix timestamp to date in React during map function
body: <p>I have a list of objects that I am mapping over to display the news on a page. The problem is the date comes to me in Unix timestamp instead of correct date format. I am trying to convert it, but every method I can find is only converting 1 item from the list.</p>
  <p>I've tried 2 different ways so far</p>
  <p>1st way:</p>
  <pre><code>return (
          &lt;Container&gt;
              {records &amp;&amp;
                  records.map((record, index) =&gt; {
                      const update = new Date(records.datetime * 1000).toLocaleDateString('en-US');
                      return (
                         &lt;span&gt;{record.update}&lt;/span&gt;
                      ))};
         &lt;/Container&gt;
  );
  </code></pre>
  <p>2nd way</p>
  <pre><code>import timestamp from 'unix-timestamp';
  
  &lt;span&gt;{timestamp.toDate(record.datetime)}&lt;/span&gt;
  </code></pre>