473,402 Members | 2,046 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,402 software developers and data experts.

mktime works fine in Red hat linux?

I am using mktime to convert the localtime value to timstamp. I am in CET zone, The returned string of the function localtime, it is correct, it matches with the date command in the shell. But the timestamp calculated by the mktime, i see it is 3 hours delayed regarding the string returned by date and localtime, why?

it is confuse .

thanks in advance,
Antonio
Dec 13 '07 #1
4 3144
RRick
463 Expert 256MB
I don't have a complete answer, there are a couple of possibilities. First, localtime and date use different structures than mktime. Localtime uses a form based on UTC and mktime uses a structure that breaks UTC into seconds, minutes, hours, etc. I suspect the breakdown occurs between the conversion of UTC to mktime.

There is also a "pesky" timezone value that lies in the background (somewhere). Try "man -k zone" for more info. I believe date uses this value to adjust the UTC times to the correct local times.

What is odd is that you are off by 3 hours instead of just 1 hour (the difference between CET and UTC) or perhaps 2 hours with daylight savings.

Perhaps someone else has an insight to this issue.
Dec 14 '07 #2
xoinki
110 100+
hi,
I have another problem.. Linux does not seem to have a 64 bit equivalent for time_t , or mktime.. in windows we have..
Expand|Select|Wrap|Line Numbers
  1. __time64_t _mktime64(
  2.    struct tm *timeptr 
  3. );
  4.  
Jan 21 '08 #3
RRick
463 Expert 256MB
The one lesson I have learned from windows is to not expect functions to work in both the windows and linux world, even if windows says its implementing a unix call. I have seen too many instances where function names are a tiny bit different and the same goes for parameters.

Hmmm, it almost like windows doesn't want you to easily port your code between platforms. Maybe we shouldn't go there.

As for UTC, I believe the 32 bit version will run out of seconds something in this century (does 2031 sound right?) I suspect before that happens, the unix world will switch from a 32 bit UTC to a 64 bit one. Maybe, windows is getting a jump start.
Jan 22 '08 #4
xoinki
110 100+
Its 2038.. y2k38 problem.. well for my application I have decided to use 32 bit one..
seems like i dnt have any option :)

Thnx and regards
Xoinki
Jan 22 '08 #5

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

Similar topics

1
by: Marcus | last post by:
Hi all, sorry to post yet another unix timestamp question, but I've been looking through php.net and google and can't find exactly what i need... plus I think my brain has shut down from too many...
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: Bengt Richter | last post by:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.mktime((1969, 12, 31, 17, 0, 0, 0, 0, 0))...
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...
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...
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...
5
by: Robert Latest | last post by:
Here's what happens on my Windows machine (Win XP / Cygwin) at work. I've googled a bit about this problem but only found references to instances where people referred to dates before the Epoch. ...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.