473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

mktime returns negative value..

110 100+
hi all,
I am trying to calculate a timestamp in unix epoch (number of seconds from 1/1/1970) from date and time info.
The tm structure is filled as follows.
Expand|Select|Wrap|Line Numbers
  1.         tm_sec    55    
  2.     tm_min    6    
  3.     tm_hour    12    
  4.     tm_mday    28    
  5.     tm_mon    11    
  6.     tm_year    107    // 2007 - 1900
  7.     tm_wday    0    
  8.     tm_yday    0    
  9.     tm_isdst 0    
  10.  
when i pass this structure to mkitime(), -1 is returned..I am trying to find out whats goin on here.. but i am not getting..

Please help
Xoinki
Jan 21 '08 #1
4 5963
weaknessforcats
9,208 Expert Mod 8TB
Probably because your year is earlier than 1970.
Jan 21 '08 #2
xoinki
110 100+
thnx for the reply.. I even tried with 2007.. its giving the same result.. Is it legal to use tm structure like this?

waiting for your reply..
Xoinki
Jan 22 '08 #3
xoinki
110 100+
hi all,
I got the solution.. there was a problem with my pointers rather than this structure.. above method gave me proper timestamp value.
just fill up the structure and use it in mktime.. u will get the proper timestamp.

Thnx and regards
xoinki
Jan 22 '08 #4
xoinki
110 100+
u shoud use tminfo.tm_year = youryear - 1900;
and tminfo.tm_mon = yourmonth - 1;
Jan 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Sandman | last post by:
Hi. On my Linux RedHat 8 system, I can't obtain dates earlier than 1970 with PHP. That is, when feeding a function that turns dfates into unixtime, such as mktime() and strtotime() print...
9
by: WebM¤nkey | last post by:
Hi folks Just found that the mktime function returns a negative value when the date is 26 march 2006 with 0 hours, 0 seconds and 0 minutes. Is this a documented problem ? Any suggestions ?
2
by: Sugapablo | last post by:
From the manual, it seems negative timestamps should work on Linux, just not Windows. But anything I try before 1970, (i.e. a negative timestamp) is giving me 12/31/1969. Is this right? --
4
by: McBooCzech | last post by:
Hi, on Linux (Fedora FC4) and Python 2.4.1 I am trying to know the time delta in seconds between two times given in the HHMMSS format. My code looks like: import datetime, time...
1
by: KW | last post by:
Hi all, Appreciate if someone can help me out on this. Currently, I have a tm structure holding information of the UTC time, which is very likely to be in the past, meaning not the current...
16
by: John Hanley | last post by:
I created a function that breaks down a date into broken down time, I subtract a certain number of seconds from that, then use mktime() to recompute the calendar time. It works basically except...
48
by: Skybuck Flying | last post by:
Hi, I came across this C code which I wanted to understand etc it looked like this: if (-1) etc It made me wonder what the result would be... true or false ? In C and Delphi
5
by: zaphod | last post by:
Fedora 3 Apache 2 PHP 5.0 I have a client's website running on Linux at www.dsvr.co.uk, a well respected hosting company, and PHP's mktime() as on many Linux versions still can't handle dates...
1
by: illegal.prime | last post by:
So I see from the documentation here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemCollectionsArrayListClassBinarySearchTopic.asp That the code uses the...
2
by: John Hanley | last post by:
I am getting some inconsistencies with mktime(). I allocate memory for my struct tm early in my program, and assign only *some* of the member variables. t->tm_sec=s; t->tm_min=m;...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.