title: Coldfusion XML PubDate Time Comparison
body: <p>I have a project I'm creating in Coldfusion 10 and it's almost done but I just need to display how long it is has been since the last update in the XML feed. I know this shouldn't be too difficult but I can't seem to figure it out.</p>
  
  <p>The project is feed by an XML feed from a publication and of all the pubdates in the feed I need to find out which pubdate is the most recent(they may not be in chronological order in the feed). I also need to compare the most recent pubdate in the feed to the current local time which is PDT and pubdates in feed are listed in GMT. I already have the XML parsed out and the pubdates are captured in a variable named "rssDate" and the pubdates are formatted like: {ts '2014-06-27 20:48:46'}.</p>
  
  <p>Here are the needed elements broken out</p>
  
  <ol>
  <li>Find most recent pubdate in the XML feed</li>
  <li>Convert the most recent pubdate (date &amp; time) from GMT to PDT and display as last update time stamp</li>
  <li>Determine the time since publication of the most recent pubdate and output as color coded display based on time ranges (see included output code).</li>
  </ol>
  
  <p>Color coded output of time since last update based upon time range</p>
  
  <pre><code>&lt;cfif timeDifference LT 1&gt;
  &lt;cfset meterColor = "4bbd07"&gt;
  &lt;cfset colorName = "Green"&gt;
  &lt;cfset messageText = "Updated less than one hour ago"&gt;
  &lt;cfelseif timeDifference GTE 1 AND timeDifference LT 1.3&gt;
  &lt;cfset meterColor = "64ff06"&gt;
  &lt;cfset colorName = "Lime"&gt;
  &lt;cfset messageText = "Updated less than one and a half hours ago"&gt;
  &lt;cfelseif timeDifference GTE 1.3 AND timeDifference LT 2&gt;
  &lt;cfset meterColor = "fffc06"&gt;
  &lt;cfset colorName = "Yellow"&gt;
  &lt;cfset messageText = "Updated more than two hours ago"&gt;
  &lt;cfelseif timeDifference GTE 2 AND timeDifference LT 2.3&gt;
  &lt;cfset meterColor = "fdae15"&gt;
  &lt;cfset colorName = "Orange"&gt;
  &lt;cfset messageText = "Updated more than two hours ago"&gt;
  &lt;cfelseif timeDifference GTE 2.3 AND timeDifference LT 3&gt;
  &lt;cfset meterColor = "ff00fc"&gt;
  &lt;cfset colorName = "Pink"&gt;
  &lt;cfset messageText = "Updated more than two and a half hours ago"&gt;
  &lt;cfelseif timeDifference GTE 3&gt;
  &lt;cfset meterColor = "fe0000"&gt;
  &lt;cfset colorName = "Red"&gt;
  &lt;cfset messageText = "Updated more than three hours ago"&gt;
  &lt;/cfif&gt;
  </code></pre>