error using mktime

This is a discussion on error using mktime within the Linux Programming forums, part of the Platform Specific Boards category; I am trying to get a time_t structure value from mktime() but it returns (time_t)-1. I am doing something like ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    15

    error using mktime

    I am trying to get a time_t structure value from mktime() but it returns (time_t)-1.
    I am doing something like this:
    struct tm tv;
    time_t timvar;
    memset() for both the variables:
    tv.tm_year = 2007;
    tv.tm_mon=12;
    tv.tm_mday=4;
    tv.hour=16;
    tv.tm_min=0;
    tv.tm_sec=0;
    timvar= mktime(&tv);
    it returns,
    Wed Dec 31 23:59:59 1969 (FFFFFFFF)

    Any help?
    Thanks & Regards,
    Amit Sahrawat

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Perhaps you want to give "year-1900", as that's what the man-page says:
    http://www.hmug.org/man/3/mktime.php

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    15
    got it ... yups it has to be year -1900, and so is for other values...

    Thanks,
    Amit Sahrawat

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. mktime issues
    By strider1974 in forum C Programming
    Replies: 3
    Last Post: 04-10-2009, 06:25 AM
  2. mktime() doesn't return meaningful value!
    By patiobarbecue in forum C Programming
    Replies: 5
    Last Post: 12-19-2008, 06:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21