Hi Bidur,

If you want an int of 2 byte for hh:mm:ss this code might help you ,
that is what I got from/for your question,

#include <stdio.h>
#include <time.h>

int main(void)
{
        time_t     now;
        struct tm  ts;
        int our_time;
        int h,m,s;

/* tm has following stuct
        struct tm {
               int tm_sec;         seconds
               int tm_min;         minutes
               int tm_hour;       hours
               int tm_mday;         day of the month
               int tm_mon;          month
               int tm_year;         year
               int tm_wday;        day of the week
               int tm_yday;        day in the year
               int tm_isdst;        daylight saving time
           };
*/

        // Get current time
        time(&now);
        printf("Epoch is :%ld",now);
        ts = *localtime(&now);
        //getting value from the struct
        printf("seconds:%d\n min:%d\n hour:%d   
\n",ts.tm_sec,ts.tm_min,ts.tm_hour);
        our_time=ts.tm_hour*3600+ts.tm_min*60+ts.tm_sec;
        //what I understand from your questin, you might be interested in 
our_time
        printf("Our time only HHMMSS %d \n",our_time);
        
        //lets try getting HH:MM:SS from the variable our_time
        s= our_time%60;
        our_time =our_time/60;
        m= our_time % 60;
        our_time =our_time/60;
        h= (our_time)%60;
        //Getting HH:MM:SS from the variable_our time
        printf("%d:%d:%d", h,m,s);
}

Hope this might be useful to you !

Thanks,
Saroj

-- 
FOSS Nepal mailing list: [email protected]
http://groups.google.com/group/foss-nepal
To unsubscribe, e-mail: [email protected]

Mailing List Guidelines: 
http://wiki.fossnepal.org/index.php?title=Mailing_List_Guidelines
Community website: http://www.fossnepal.org/

Reply via email to