Thread: Time function

  1. #1
    Registered User
    Join Date
    Jan 2008

    Time function

    I am working with time function and what I inderstand is that if you have now=time(NULL) and you output time you will get the number of seconds that have passed since Jan, 01, 1970. Please correct me if I am wrong on this.
    What I am trying to do is have a user input a date and for the program to count seconds from that date. What would now variable have to equal to in this case ?

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    Depends on the input. Perhaps some date functions can help you?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    >Please correct me if I am wrong on this.
    The value is the current time, whose value and representation remain unknown to you. It doesn't have to be seconds since the Unix epoch, so you should refrain from relying on that.

    >What would now variable have to equal to in this case ?
    You shouldn't diddle with time_t. Instead, use the tm struct. You can fill up the members of that structure and then use mktime to portably build a time_t value. From there you can use difftime to get a count of seconds.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  2. Sending an email in C program
    By Moony in forum C Programming
    Replies: 28
    Last Post: 10-19-2006, 10:42 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Replies: 5
    Last Post: 02-08-2003, 07:42 PM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM