<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Time difference.</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/21105/time-difference</link><description> 
I wan to find the time difference between Current time and the
Previous time. 

 
In my project i maintain some time interval and that interval is
checked by converting the both previous and current time to entire
seconds and find the difference. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Time difference.</title><link>https://community.arm.com/thread/98688?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2006 06:59:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c23d5eba-c8be-48a2-9ed5-d15b47e1c4a3</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Your problem is because you have only time and not date;&lt;br /&gt;
therefore, you have to assume that the date must have changed if the
times are in the &amp;quot;wrong order&amp;quot;&lt;/p&gt;

&lt;pre&gt;
if( current_time &amp;gt;= previous_time )
{
   // both times are from the same day
}
else
{
   // previous_time is later than current time!
   // Must assume that previous time refers to
   // a previous day...
}


&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time difference.</title><link>https://community.arm.com/thread/74605?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2006 06:37:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0f23079b-32bb-4cfe-8527-2546615bde2c</guid><dc:creator>Gowri Shankar</dc:creator><description>&lt;p&gt;&lt;pre&gt;
void Time_Secs_Calculation(void)
  {
Temp_1 = Hex2Dec(ch[2]);  //DECIMAL VALUE of hr
Temp_2 = Hex2Dec(ch[1]);  //decimal value of min
Temp_3 = Hex2Dec(ch[0]);  //decimal value of sec

if((Temp_1 == 0) &amp;amp;&amp;amp; (Temp_2 == 0) &amp;amp;&amp;amp; (Temp_3 == 0))
  {
     Temp_1 = 23;
     Temp_2 = 60;
  }

 Time_1 = (((unsigned long int)(Temp_1)*60*60) + ((unsigned long int)(Temp_2)*60) + (unsigned long int)(Temp_3));  //GET THE TOTAL CURRENT TIME interms of sec

Time_2 = (((unsigned long int)(Prev_Hr)*60*60) + ((unsigned long int)(Prev_Min)*60) + (unsigned long int)(Prev_Sec)); //GET THE PREVIOUS TIME interms of sec

 Time = Time_1 - Time_2;   //DIFFERENCE TIME = CURRENT
                           //  TIME - PREVIOUS TIME

 SBUF=&amp;#39; &amp;#39;;
 printf(&amp;quot;\n Time diff is %lu&amp;quot;,Time);
 TI = 0;
 Delay(1000);

Temp   = ((unsigned int)(Time) / 60);             //GET THE QUOTIENT TO GET MINUTES AND HOUR

Diff_Hr  = (Temp / 60);  //GET THE DIFFERENCE OF HOURS
Diff_Min = (Temp % 60); //GET THE DIFFERENCE OF mins
Diff_Sec = (Time % 60);  //GET THE DIFFERENCE OF secs

intSec_Diff = ((Diff_Min*60) + Diff_Sec);

return;
  }
&lt;/pre&gt;

&lt;p&gt;
this is my coding.&lt;/p&gt;

&lt;p&gt;
the probelm comes when the previous time and current time are said
as abopve already since the variable,&lt;/p&gt;

&lt;p&gt;
intSec_Diff is the variable maintaining the interval between
previous and current time in terms of seconds.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Time difference.</title><link>https://community.arm.com/thread/47340?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2006 06:31:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:97aa8588-a845-4fbf-8364-22707c4a504d</guid><dc:creator>Christoph Franck</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;can any suggest me how this can be rectifed?&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
By checking whether overflow occurs, and then treating the case
differently from a no-overflow situation.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>