Thread: Substract 2 date, one is current date

  1. #1
    Registered User
    Join Date
    Mar 2018
    Posts
    2

    Substract 2 date, one is current date

    I know this sounds stupid but I have never dealt with time before, only to generate random numbers in C
    My question is I have current time and a time in the past and I need to calculate the distance/diffence between them (I have exact hour and minute) so need to show time accurate up to minute

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Like difftime / mktime in time.h.
    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
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Cool... what's the problem? Just get the difference and divide by 60, like this:
    Code:
    minsPassed = (curTime - prevTime)/60.0;
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting current date and time in C++
    By Ashwin Kumar in forum C++ Programming
    Replies: 1
    Last Post: 12-30-2014, 12:23 PM
  2. current date
    By cnu_sree in forum C Programming
    Replies: 5
    Last Post: 06-05-2007, 11:50 PM
  3. How do I get the current date in my code?
    By FromHolland in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2003, 01:37 PM
  4. How do you get the current date?
    By cerial-killer in forum C++ Programming
    Replies: 4
    Last Post: 03-18-2003, 03:50 PM
  5. File I/O with a current Date
    By Kyoto Oshiro in forum C++ Programming
    Replies: 4
    Last Post: 07-12-2002, 10:56 PM

Tags for this Thread