title: Javascript to determine date and output either "time" if it is today, "yesterday" for yesterday, and the actual date if it is before then
body: <p>I am creating an simple email client and I want the inbox to display the date that the email was received in the format:</p>
  
  <p>Today at 13:17</p>
  
  <p>Yesterday at 20:38</p>
  
  <p>13 January at 17:15</p>
  
  <p>21 December 2012 @ 18:12</p>
  
  <p>I am retrieving the data from a database, outputting it to xml (so everything can be done through AJAX) and printing the results to a <code>&lt;ul&gt;&lt;li&gt;</code> format.</p>
  
  <p>The Date and Time are stored separately in the format:</p>
  
  <p><code>Date(y-m-d)</code></p>
  
  <p><code>Time(H:i:s)</code></p>
  
  <p><img src="https://i.stack.imgur.com/mxNtl.png" alt="what i have so far"></p>
  
  <p>I see that something like that is possible with php. Here - <a href="https://stackoverflow.com/questions/3454258/php-date-yesterday-today">PHP: date &quot;Yesterday&quot;, &quot;Today&quot;</a></p>
  
  <p>Is this possible using javascript?</p>