473,387 Members | 1,624 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,387 software developers and data experts.

mktime fails for pre 1970 on Fedora 3

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 can't believe the PHP developers continute to keep
their head in the sand with regard to mktime() and it's problems dealing
with dates prior to 1970. It's no good blaming glibc. If glibc is
problematic dependence on it should have been dropped long ago. Perl's
Date::Calc doesn't suffer from these problems.

zaphod
Nov 29 '05 #1
5 2248
zaphod <no**@none.com> wrote:

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 can't believe the PHP developers continute to keep
their head in the sand with regard to mktime() and it's problems dealing
with dates prior to 1970. It's no good blaming glibc. If glibc is
problematic dependence on it should have been dropped long ago. Perl's
Date::Calc doesn't suffer from these problems.


It's not glibc. It is much more deeply embedded in the depths of the
operating system. Just try to work with a date past February, 2038.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Nov 29 '05 #2
>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 can't believe the PHP developers continute to keep
their head in the sand with regard to mktime() and it's problems dealing
with dates prior to 1970. It's no good blaming glibc. If glibc is
problematic dependence on it should have been dropped long ago. Perl's
Date::Calc doesn't suffer from these problems.


I wish PHP had a date representation OTHER than a unix timestamp
for date calculations. Pretty much all of the date/time functions
are limited by this. Of course, changing this is going to be a
problem because there are undoubtedly lots of scripts that store
that representation in files or databases. A 32-bit Unix timestamp
is limited to 1970 - 2038 for the "positive" range, and depending
on whether it's considered signed or unsigned, to 1901-1969 or
2038-2106 for the part with the high bit set.

MySQL uses a text representation of the form: 2005-11-28 15:01:38.
It has potential Y10K problems, but most of the date/time functions
other than the couple which input or output a unix timestamp are
not limited to a couple of centuries. Functions like adding x
seconds to a timestamp are, however, much more complicated and
there's a lot of functionality I'd like to see that isn't implemented.

I prefer to use MySQL's date math where the date involved isn't
tied to something like a file stamp. For example, a UNIX timestamp
is hopeless for birth dates or expected retirement dates.

Gordon L. Burditt
Nov 29 '05 #3
On Tue, 29 Nov 2005 17:54:37 -0000, go***********@burditt.org (Gordon Burditt)
wrote:
I wish PHP had a date representation OTHER than a unix timestamp
for date calculations.


There's always http://pear.php.net/package/Date

PHP 5.1.0 had a "new native date class" for about 5 minutes until they
withdrew it in 5.1.1 - not sure of the details of that.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 29 '05 #4
Tim Roberts wrote:
It's not glibc. It is much more deeply embedded in the depths of the
operating system. Just try to work with a date past February, 2038.


I'm not referring to the 32/64 bit issue. On some UNIX platforms, such as
FreeBSD, mktime handles pre-1970 dates with a workable negative value. On
many Linux distros all you get for anything before 1 Jan 1970 is -1. If
Perl's Date::Calc can handle all this why can't PHP?

zaphod
Nov 30 '05 #5
>> It's not glibc. It is much more deeply embedded in the depths of the
operating system. Just try to work with a date past February, 2038.
I'm not referring to the 32/64 bit issue.


This isn't the 32/64 bit issue. This is the 31/32 bit issue.
On some UNIX platforms, such as
FreeBSD, mktime handles pre-1970 dates with a workable negative value. On
many Linux distros all you get for anything before 1 Jan 1970 is -1. If
Perl's Date::Calc can handle all this why can't PHP?


An OS with a 32-bit time_t has a choice. With the "negative" values
of a 32-bit integer, it can represent 1901-1969 or 2038-2106: pick
one. I take it Linux chose to handle 2038-2106, and you don't like
that choice.

I think POSIX says it's supposed to be unsigned, so arguably
Linux is right and the BSDs are wrong as far as standards compliance.
Gordon L. Burditt
Nov 30 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Cal Lidderdale | last post by:
PHP doesn't have ENUM and I'm inputting the date 14-SEP-2003 and I want to "insert into atable values ('2003-09-14', .........==> mysql. Anybody have a neet trick? Tks Chuck
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...
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...
4
by: Maziar Aflatoun | last post by:
Hi, Can someone please tell me how I can set DateTime to 01/01/1970 (UTC). Doing the following DateTime dt1 = new DateTime(1970, 1,1); Debug.WriteLine("dt1(utc):"+...
4
by: xoinki | last post by:
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. tm_sec 55 tm_min 6 ...
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: 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: 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:
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
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...

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.