473,569 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mktime returns negative value..

110 New Member
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 6010
weaknessforcats
9,208 Recognized Expert Moderator Expert
Probably because your year is earlier than 1970.
Jan 21 '08 #2
xoinki
110 New Member
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 New Member
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 New Member
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
3279
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 date("Y-m-d", mktime(0,0,0,1,1,1930)); -> "1969-12-31" (since the result of mktime is "-1") But date() gets it though, so if I do
9
2174
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
2800
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
10235
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 ta1=(time.strptime('000001', '%H%M%S')) ta2=(time.strptime('230344', '%H%M%S')) t1=time.mktime(ta1) t2=time.mktime(ta2) print t1, t2
1
24518
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 time. So, let's say I'm in CST(-6) now, and I want to know the equivalent local time of that tm structure, how do I do that taking into consideration...
16
14309
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 every so often, I get the date 060207 (Feb 7, 2006) which is obviously not correct. When it does this it always gives me this date. I tracked it...
48
30073
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
2259
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 prior to 1970. This is madness. Can anyone explain why the problem with mktime()'s dependence on glibc STILL hasn't been addressed as of PHP 5? I...
1
4796
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 less than operator: int myIndex=myList.BinarySearch( myObject ); if ( myIndex < 0 ) when using the BinarySearch method and in my own experience I...
2
3950
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; t->tm_hour=h; t->tm_mday=d;
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.