Thread: calculate hours

  1. #1
    Registered User
    Join Date
    Oct 2017
    Posts
    5

    calculate hours

    I would like to calculate hours between two dates. Any ideas out there? Anything will be appreciated. I have tried a few different ways, I don't know if difftime is the answer but I can't seems to get help anywhere relating to difftime

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2011
    Location
    Namib desert
    Posts
    94
    You can convert date A into a time_t value (seconds passed since 00:00:00 on January 1, 1970) and do the same with date B. Next use difftime()

    In order to convert a certain date into an above mentioned time_t you will need a "struct tm" and the function mktime()

  4. #4
    Registered User
    Join Date
    Oct 2017
    Posts
    5
    Thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need Immediate help with a problem due in a few hours....
    By dmcarpenter in forum C Programming
    Replies: 2
    Last Post: 02-14-2013, 11:38 PM
  2. 7 hours?
    By Jeffery in forum C Programming
    Replies: 1
    Last Post: 10-10-2010, 02:49 AM
  3. We missed REALLY big day (by about 17 hours)
    By major_small in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-20-2005, 07:53 PM
  4. How many hours/day at cprogramming.com ?
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 01-28-2003, 11:08 PM
  5. Xp Locks Up after about 2 hours :(
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 02-11-2002, 11:25 AM

Tags for this Thread