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
print date("Y-m-d", -1000000000);
-> "1938-04-24"
Now, presumably this has something to do with Linux instead of PHP, since doing
this in MySQL doesn't work either:
select unix_timestamp('1935-12-03');
-> 0
But, when using perl, it works just fine when using Date::Manip:
#!/usr/bin/perl
use Date::Manip;
$date = UnixDate("1945-01-23", "%s");
print $date;
-> -787021200
So, how come MySQL can't do it, PHP can't do it, but somehow perl can? Can I
compile PHP with negative integer date support?
--
Sandman[.net] 12 3273
Hi Sandman!
On Wed, 18 Feb 2004 09:59:52 +0100, Sandman <mr@sandman.net> wrote: 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
print date("Y-m-d", -1000000000); -> "1938-04-24"
Now, presumably this has something to do with Linux instead of PHP, since doing this in MySQL doesn't work either:
select unix_timestamp('1935-12-03'); -> 0
But, when using perl, it works just fine when using Date::Manip:
#!/usr/bin/perl use Date::Manip; $date = UnixDate("1945-01-23", "%s"); print $date; -> -787021200
So, how come MySQL can't do it, PHP can't do it, but somehow perl can? Can I compile PHP with negative integer date support?
I think it depends on the underlying unix libraries. I think a better
approach would IMO to write a library based on the MySQL date
functions (or any other database), which should support date support
from 1908-xxxx or earlier. The SQL-92 functions ar much more
rudimentary than what PHP offers, but with some regexes you should get
something going. For dates before 1908 you should ask anyway "Where?",
I was amazed reading Joe Celko's "SQL for Smarties"
HTH, Jochen
In article <je********************************@4ax.com>,
Jochen Daum <jd@jdaum.de> wrote: 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
print date("Y-m-d", -1000000000); -> "1938-04-24"
Now, presumably this has something to do with Linux instead of PHP, since doing this in MySQL doesn't work either:
select unix_timestamp('1935-12-03'); -> 0
But, when using perl, it works just fine when using Date::Manip:
#!/usr/bin/perl use Date::Manip; $date = UnixDate("1945-01-23", "%s"); print $date; -> -787021200
So, how come MySQL can't do it, PHP can't do it, but somehow perl can? Can I compile PHP with negative integer date support?
I think it depends on the underlying unix libraries. I think a better approach would IMO to write a library based on the MySQL date functions (or any other database), which should support date support from 1908-xxxx or earlier.
Eh, I don't understand... Are you recommending I use MySQL to obtain dates
earlier than 1970 even though I showed above that MySQL doesn't support it
either...? I am confused.
To recap again. MySQL doesn't support it, PHP doesn't support it, Perl supports
it.
--
Sandman[.net]
Hi Sandman!
On Wed, 18 Feb 2004 10:51:08 +0100, Sandman <mr@sandman.net> wrote: In article <je********************************@4ax.com>, Jochen Daum <jd@jdaum.de> wrote:
>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 > > print date("Y-m-d", -1000000000); > -> "1938-04-24" > >Now, presumably this has something to do with Linux instead of PHP, since >doing this in MySQL doesn't work either: > > select unix_timestamp('1935-12-03'); > -> 0 > >But, when using perl, it works just fine when using Date::Manip: > > #!/usr/bin/perl > use Date::Manip; $date = UnixDate("1945-01-23", "%s"); print $date; > -> -787021200 > >So, how come MySQL can't do it, PHP can't do it, but somehow perl can? Can >I compile PHP with negative integer date support?
I think it depends on the underlying unix libraries. I think a better approach would IMO to write a library based on the MySQL date functions (or any other database), which should support date support from 1908-xxxx or earlier.
Eh, I don't understand... Are you recommending I use MySQL to obtain dates earlier than 1970 even though I showed above that MySQL doesn't support it either...? I am confused.
To recap again. MySQL doesn't support it, PHP doesn't support it, Perl supports it.
If you look at http://www.mysql.com/doc/en/Date_and...functions.html
and just do not use any %UNIX% functions, you should be fine. I just
tested
SELECT INTERVAL 1 DAY + '1925-12-31'
and its New Years day 1926.
HTH, Jochen
In article <5h********************************@4ax.com>,
Jochen Daum <jd@jdaum.de> wrote: >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 > > print date("Y-m-d", -1000000000); > -> "1938-04-24" > >Now, presumably this has something to do with Linux instead of PHP, >since doing this in MySQL doesn't work either: > > select unix_timestamp('1935-12-03'); > -> 0 > >But, when using perl, it works just fine when using Date::Manip: > > #!/usr/bin/perl > use Date::Manip; $date = UnixDate("1945-01-23", "%s"); print $date; > -> -787021200 > >So, how come MySQL can't do it, PHP can't do it, but somehow perl can? >Can I compile PHP with negative integer date support?
I think it depends on the underlying unix libraries. I think a better approach would IMO to write a library based on the MySQL date functions (or any other database), which should support date support from 1908-xxxx or earlier.
Eh, I don't understand... Are you recommending I use MySQL to obtain dates earlier than 1970 even though I showed above that MySQL doesn't support it either...? I am confused.
To recap again. MySQL doesn't support it, PHP doesn't support it, Perl supports it.
If you look at http://www.mysql.com/doc/en/Date_and...functions.html
and just do not use any %UNIX% functions, you should be fine. I just tested
SELECT INTERVAL 1 DAY + '1925-12-31'
and its New Years day 1926.
I realize that - but perhaps I was unclear at what I wanted. I WANT the unix
timestamp of a given date.
select unix_timestamp("1985-01-01");
-> 473382000
select unix_timestamp("1925-01-01");
-> 0
What that other select SHOULD return is "-1420074000" and THAT's what I want. I
want a function, prefferably in PHP, that will return "-1420074000" when I feed
it with "1925-01-01".
--
Sandman[.net]
Hi Sandman!
On Wed, 18 Feb 2004 12:00:19 +0100, Sandman <mr@sandman.net> wrote: In article <5h********************************@4ax.com>, Jochen Daum <jd@jdaum.de> wrote:
>> >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 >> > >> > print date("Y-m-d", -1000000000); >> > -> "1938-04-24" >> > >> >Now, presumably this has something to do with Linux instead of PHP, >> >since doing this in MySQL doesn't work either: >> > >> > select unix_timestamp('1935-12-03'); >> > -> 0 >> > >> >But, when using perl, it works just fine when using Date::Manip: >> > >> > #!/usr/bin/perl >> > use Date::Manip; $date = UnixDate("1945-01-23", "%s"); print $date; >> > -> -787021200 >> > >> >So, how come MySQL can't do it, PHP can't do it, but somehow perl can? >> >Can I compile PHP with negative integer date support? >> >> I think it depends on the underlying unix libraries. I think a better >> approach would IMO to write a library based on the MySQL date functions >> (or any other database), which should support date support from 1908-xxxx >> or earlier. > >Eh, I don't understand... Are you recommending I use MySQL to obtain dates >earlier than 1970 even though I showed above that MySQL doesn't support it >either...? I am confused. > >To recap again. MySQL doesn't support it, PHP doesn't support it, Perl >supports it. If you look at http://www.mysql.com/doc/en/Date_and...functions.html
and just do not use any %UNIX% functions, you should be fine. I just tested
SELECT INTERVAL 1 DAY + '1925-12-31'
and its New Years day 1926.
I realize that - but perhaps I was unclear at what I wanted. I WANT the unix timestamp of a given date.
select unix_timestamp("1985-01-01"); -> 473382000
select unix_timestamp("1925-01-01"); -> 0
Thats because the Unix Epoch is from 1970 to 2038. The result is IMO
undefined for dates outside. What that other select SHOULD return is "-1420074000" and THAT's what I want. I want a function, prefferably in PHP, that will return "-1420074000" when I feed it with "1925-01-01".
Its an understandable opinion, but I would dicuss it with the guys
that do the unix date libraries. That might clear it.
HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces. http://sourceforge.net/projects/phpdbedittk/
In article <f7********************************@4ax.com>,
Jochen Daum <jo*********@cans.co.nz> wrote: I realize that - but perhaps I was unclear at what I wanted. I WANT the unix timestamp of a given date.
select unix_timestamp("1985-01-01"); -> 473382000
select unix_timestamp("1925-01-01"); -> 0
Thats because the Unix Epoch is from 1970 to 2038. The result is IMO undefined for dates outside.
Well, the unix epoch is system-dependant, on some unix systems it's frm 1970,
and from some it's 1904. It all depends on whether the date integer can handle
inverse values (i.e. 0 is 1970-01-01 00:00:00 and -1 is 1969-12-31 23:59:59).
It's the scope of a 32 bit integer. What that other select SHOULD return is "-1420074000" and THAT's what I want. I want a function, prefferably in PHP, that will return "-1420074000" when I feed it with "1925-01-01".
Its an understandable opinion, but I would dicuss it with the guys that do the unix date libraries. That might clear it.
Yes, it seems they don't use the system date functions, and I was hoping to
find a way to make PHP do the same... :/
--
Sandman[.net]
"Sandman" <mr@sandman.net> wrote in message
news:mr**********************@news.fu-berlin.de... In article <f7********************************@4ax.com>, Jochen Daum <jo*********@cans.co.nz> wrote:
What that other select SHOULD return is "-1420074000" and THAT's what I want. I want a function, prefferably in PHP, that will return "-1420074000" when I feed it with "1925-01-01".
it seems they don't use the system date functions, and I was hoping to find a way to make PHP do the same... :/
How about returning -1420052400 instead?
Have you looked at ADOdb?
I've a scratch page with various conversions at http://www.boclair.com/adodb_test-time2.php.
Louise
In article <c1*************@ID-210679.news.uni-berlin.de>,
"boclair" <bo*****@bigpond.net.au> wrote: > What that other select SHOULD return is "-1420074000" and THAT's what > I want. I want a function, prefferably in PHP, that will return > "-1420074000" when I feed it with "1925-01-01".
it seems they don't use the system date functions, and I was hoping to find a way to make PHP do the same... :/
How about returning -1420052400 instead?
Have you looked at ADOdb?
I've a scratch page with various conversions at http://www.boclair.com/adodb_test-time2.php.
Hello - that looks nice!
What is ADOdb? How do I get the adodb.inc.php file?
--
Sandman[.net]
"Sandman" <mr@sandman.net> wrote in message
news:mr**********************@news.fu-berlin.de... In article <c1*************@ID-210679.news.uni-berlin.de>, "boclair" <bo*****@bigpond.net.au> wrote:
What is ADOdb? How do I get the adodb.inc.php file?
A GPL program consisting of libraries and PHP classes which standardizes
access across many (most) database programs. Does much more than just
date/time conversions. Very powerful.
See http://php.weblogs.com/adodb .
To begin you might find the following useful. http://www.phpfreaks.com/tutorials/110/0.php
Louise
In article <c1*************@ID-210679.news.uni-berlin.de>,
"boclair" <bo*****@bigpond.net.au> wrote: What is ADOdb? How do I get the adodb.inc.php file?
A GPL program consisting of libraries and PHP classes which standardizes access across many (most) database programs. Does much more than just date/time conversions. Very powerful.
See http://php.weblogs.com/adodb .
To begin you might find the following useful. http://www.phpfreaks.com/tutorials/110/0.php
Ok, now I'm confused. This seems to be a Database bridge API, to make the
database backend to a PHP frontend interchangeable.
Well, first off - that seems a bit tad over the top to implement just to do
what I wanted.
And second - how do I know that the function adodb_mktime() doesn't use a
database backend to perform this query and it is the functions of THAT database
that enables mktime() to reference dates older than 1970?
Now, presumably I could just download it and look at the source - but posting
this was more fun. :)
--
Sandman[.net]
The central purpose of ADOdb is, as you say, to allow standardized
connections to various db engines and to query, insert etc data table
through php scripting.
However once results have been got there are a number of functions available
for manipulating the
result variables, including date/time. However the variables can be
created in any manner including directly as in the scratch page at http://www.boclair.com/adodb_test-time2.php
The library is very light but if you want to slim it down further,
adodb-time.inc.php is the effective include. (adodb.inc.php is needed to
access it).
The functions are at http://php.weblogs.com/adodb_date_time_library.
Louise
The central purpose of ADOdb is, as you say, to allow standardized
connections to various db engines and to query, insert etc data table
through php scripting.
However once results have been got there are a number of functions available
for manipulating the
result variables, including date/time. However the variables can be
created in any manner including directly as in the scratch page at http://www.boclair.com/adodb_test-time2.php
The library is very light but if you want to slim it down further,
adodb-time.inc.php is the effective include. (adodb.inc.php is needed to
access it).
The functions are at http://php.weblogs.com/adodb_date_time_library.
Louise
"Sandman" <mr@sandman.net> wrote in message
news:mr**********************@news.fu-berlin.de... In article <c1*************@ID-210679.news.uni-berlin.de>, "boclair" <bo*****@bigpond.net.au> wrote:
What is ADOdb? How do I get the adodb.inc.php file? A GPL program consisting of libraries and PHP classes which
standardizes access across many (most) database programs. Does much more than just date/time conversions. Very powerful.
See http://php.weblogs.com/adodb .
To begin you might find the following useful. http://www.phpfreaks.com/tutorials/110/0.php
Ok, now I'm confused. This seems to be a Database bridge API, to make the database backend to a PHP frontend interchangeable.
Well, first off - that seems a bit tad over the top to implement just to
do what I wanted.
And second - how do I know that the function adodb_mktime() doesn't use a database backend to perform this query and it is the functions of THAT
database that enables mktime() to reference dates older than 1970?
Now, presumably I could just download it and look at the source - but
posting this was more fun. :)
-- Sandman[.net]
In article <c1*************@ID-210679.news.uni-berlin.de>,
"boclair" <bo*****@bigpond.net.au> wrote: The central purpose of ADOdb is, as you say, to allow standardized connections to various db engines and to query, insert etc data table through php scripting.
However once results have been got there are a number of functions available for manipulating the result variables, including date/time. However the variables can be created in any manner including directly as in the scratch page at http://www.boclair.com/adodb_test-time2.php
The library is very light but if you want to slim it down further, adodb-time.inc.php is the effective include. (adodb.inc.php is needed to access it).
The functions are at http://php.weblogs.com/adodb_date_time_library.
Regardless of databases, the TIME functions was seperately downloadable, and
they work just fine!
Thanks!
--
Sandman[.net] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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))...
|
by: Florian Quetting |
last post by:
Hi,
I'm getting mad with following problem: The code compiles, but I always get
a segfault and I don't have any clue why. I can't see any differences in my
way of calling mktime and others.
...
|
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...
|
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...
|
by: KfirShtober |
last post by:
Hello.
I have a task to develop a calendar in C#, therefore - I need to use unixtime I think.
But I don't know how to, can some one explain to me how to convert the date of today to unix time?...
| |
by: Mark |
last post by:
I want to simply get the unix style epoch time
(number of secs to now from Jan 01, 1970 UTC) for
use as a timestamp to track the staleness of some
objects. So I don't care about time zones or...
|
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 ...
|
by: smitanaik |
last post by:
hi
i have unixtime format 1075329297.572 how do i store it in database.that is with what datatype.i tried to store unixtime using date, timestamp but it does not work.
but with varchar2 it works....
|
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.
...
|
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...
|
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: 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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |