Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
-
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)? -
I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments? -
If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?
PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.
--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
What's insufficient in strtotime()
and strftime()
?
George
Hello George,
Because they both operate on an integer timestamp...
two things:
SELECT CURDATE() + INTERVAL 7 MONTH;
echo strtotime("7/12/1900");
Timestamps are fine for things that are happening within a very limited
range of dates. How do you add a given number of months to a date?
how do you get the day of week for a given date? These are the
types of functions that I am thinking of.
--
Best regards,
Jason mailto:jason@ionzoft.com
Monday, August 2, 2004, 10:40:45 PM, you wrote:
GS> On Aug 2, 2004, at 10:36 PM, Jason Garber wrote:
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
GS> What's insufficient in strtotime()
and strftime()
?
GS> George
Hello George,
Because they both operate on an integer timestamp...
two things:
SELECT CURDATE() + INTERVAL 7 MONTH;
echo strtotime("7/12/1900");Timestamps are fine for things that are happening within a very limited
range of dates. How do you add a given number of months to a date?
how do you get the day of week for a given date? These are the
types of functions that I am thinking of.
echo strtotime("now +7 months");
echo date('l', strtotime('2004-10-02')); || echo strftime('%A',
strtotime('2004-10-02')); (latter supports locales)
http://php.net/strtotime
http://php.net/strftime
http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html
-bok
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.What's insufficient in
strtotime()
andstrftime()
?
They behave badly and are OS dependent... which makes it quite a mess in
the code too; which is very hard to maintain now.
Derick
http://pecl.php.net/package-info.php?package=Date
It's not in the core because it is still relatively young.
Maybe in a future release...
--Wez.
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
Hello Wez,
I must be missing something... I went to the link and couldn't find
any documentation. I downloaded it and all the .tgz contained were a
couple of .php scripts?
--
Best regards,
Jason mailto:jason@ionzoft.com
Monday, August 2, 2004, 10:41:09 PM, you wrote:
WF> http://pecl.php.net/package-info.php?package=Date
WF> It's not in the core because it is still relatively young.
WF> Maybe in a future release...
WF> --Wez.
WF> On Mon, 2 Aug 2004 22:36:14 -0400, Jason Garber jason@ionzoft.com wrote:
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
Urgh, blame PEAR for that ;-)
There is a PECL date extension that you can obtain from our CVS
(see http://www.php.net/anoncvs.php):
cvs -d :pserver:cvsread@cvs.php.net:/repository co pecl/date
cd pecl/date
phpize
./configure
make install
[ add date.so to php.ini ]
--Wez.
Hello Wez,
I must be missing something... I went to the link and couldn't find
any documentation. I downloaded it and all the .tgz contained were a
couple of .php scripts?--
Best regards,
Jason mailto:jason@ionzoft.comMonday, August 2, 2004, 10:41:09 PM, you wrote:
WF> http://pecl.php.net/package-info.php?package=Date
WF> It's not in the core because it is still relatively young.
WF> Maybe in a future release...WF> --Wez.
WF> On Mon, 2 Aug 2004 22:36:14 -0400, Jason Garber jason@ionzoft.com wrote:
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
I always wished that PHP had VB's set of operators on dates/times... (and
also in SQL): year(), month(), date()
, time_serial(), and the like. Yes, you
can do it with date("...", $x); but then it's just awkward to remember all
the operators.
Also, I'd always wished that PHP would have support for dates after 32 bit
(2037)... when do you think Pecl's Date would get into PHP?
Jevon
----- Original Message -----
From: "Jason Garber" jason@ionzoft.com
To: internals@lists.php.net
Sent: Tuesday, August 03, 2004 2:36 PM
Subject: [PHP-DEV] Date Support
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
I always wished that PHP had VB's set of operators on dates/times... (and
also in SQL): year(), month(),date()
, time_serial(), and the like. Yes, you
can do it with date("...", $x); but then it's just awkward to remember all
the operators.
Good point, I'll add that to the list.
Also, I'd always wished that PHP would have support for dates after 32 bit
(2037)... when do you think Pecl's Date would get into PHP?
The thing I'm working on should work for larger ranges than the 32bit
range, except that I can't do DST information outside the range, as the
timezone information files can not contain this :I
Derick
Hi
There's a library that i wrote that supports timestamps > 2037.
It takes advantage of the fact that PHP converts integers to floats on
overflow. It uses the nearly the same api as date()
and mktime()
, to make
porting easier.
Regards, John
See http://phplens.com/phpeverywhere/adodb_date_library
"Jevon Wright" jevon@jevon.org wrote in message
news:011601c47920$8d116ba0$0a00a8c0@home.jevon.org...
I always wished that PHP had VB's set of operators on dates/times... (and
also in SQL): year(), month(),date()
, time_serial(), and the like. Yes,
you
can do it with date("...", $x); but then it's just awkward to remember all
the operators.Also, I'd always wished that PHP would have support for dates after 32 bit
(2037)... when do you think Pecl's Date would get into PHP?Jevon
----- Original Message -----
From: "Jason Garber" jason@ionzoft.com
To: internals@lists.php.net
Sent: Tuesday, August 03, 2004 2:36 PM
Subject: [PHP-DEV] Date SupportHello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.
Hello John,
how does that help? I mean sizeof(double) == 4 == sizeof(int/32).
In other words the bitsize is the same. Only you get an exponent.
The result is that you loose time information accuracy.
regards
marcus
Tuesday, August 3, 2004, 10:34:18 AM, you wrote:
Hi
There's a library that i wrote that supports timestamps > 2037.
It takes advantage of the fact that PHP converts integers to floats on
overflow. It uses the nearly the same api asdate()
andmktime()
, to make
porting easier.
Regards, John
"Jevon Wright" jevon@jevon.org wrote in message
news:011601c47920$8d116ba0$0a00a8c0@home.jevon.org...I always wished that PHP had VB's set of operators on dates/times... (and
also in SQL): year(), month(),date()
, time_serial(), and the like. Yes,
you
can do it with date("...", $x); but then it's just awkward to remember all
the operators.Also, I'd always wished that PHP would have support for dates after 32 bit
(2037)... when do you think Pecl's Date would get into PHP?Jevon
----- Original Message -----
From: "Jason Garber" jason@ionzoft.com
To: internals@lists.php.net
Sent: Tuesday, August 03, 2004 2:36 PM
Subject: [PHP-DEV] Date SupportHello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an acceptable
set of functions?PHP is a feature packed language, but it's strange that this does not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.--
--
Best regards,
Marcus mailto:helly@php.net
Hi Marcus,
For 32 bit architectures, normally:
sizeof(float) == 4, sizeof(double) == 8 or 10
So there is no floating point overflow fortunately.
E.g. http://www.iota-six.co.uk/c/b3_float_double_and_sizeof.asp
PS: i think the date()
and mktime()
functions could be extended using the
algorithms described in the date library, if anyone is interested. It would
make date( ) and mktime()
much more user friendly.
"Marcus Boerger" helly@php.net wrote in message
news:1912137764.20040803104457@marcus-boerger.de...
Hello John,
how does that help? I mean sizeof(double) == 4 == sizeof(int/32).
In other words the bitsize is the same. Only you get an exponent.
The result is that you loose time information accuracy.regards
marcusTuesday, August 3, 2004, 10:34:18 AM, you wrote:
Hi
There's a library that i wrote that supports timestamps > 2037.
It takes advantage of the fact that PHP converts integers to floats on
overflow. It uses the nearly the same api asdate()
andmktime()
, to
make
porting easier.Regards, John
"Jevon Wright" jevon@jevon.org wrote in message
news:011601c47920$8d116ba0$0a00a8c0@home.jevon.org...I always wished that PHP had VB's set of operators on dates/times...
(and
also in SQL): year(), month(),date()
, time_serial(), and the like.
Yes,
you
can do it with date("...", $x); but then it's just awkward to remember
all
the operators.Also, I'd always wished that PHP would have support for dates after 32
bit
(2037)... when do you think Pecl's Date would get into PHP?Jevon
----- Original Message -----
From: "Jason Garber" jason@ionzoft.com
To: internals@lists.php.net
Sent: Tuesday, August 03, 2004 2:36 PM
Subject: [PHP-DEV] Date SupportHello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really
good
set of functions for dealing with true date and time types (i.e.
not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools
for
handling dates. I think that this style of date handling, where
the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to
go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an
acceptable
set of functions?PHP is a feature packed language, but it's strange that this does
not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.--
--
Best regards,
Marcus mailto:helly@php.net
Hello John,
ups you're right of course, i must be dreaming.
Maybe you should talk to Derick about the internal functions
and you should also have a look at pecl/date.
marcus
Tuesday, August 3, 2004, 11:32:38 AM, you wrote:
Hi Marcus,
For 32 bit architectures, normally:
sizeof(float) == 4, sizeof(double) == 8 or 10
sizeof(long double) == 10
So there is no floating point overflow fortunately.
E.g. http://www.iota-six.co.uk/c/b3_float_double_and_sizeof.asp
PS: i think the
date()
andmktime()
functions could be extended using the
algorithms described in the date library, if anyone is interested. It would
make date( ) andmktime()
much more user friendly.
"Marcus Boerger" helly@php.net wrote in message
news:1912137764.20040803104457@marcus-boerger.de...Hello John,
how does that help? I mean sizeof(double) == 4 == sizeof(int/32).
In other words the bitsize is the same. Only you get an exponent.
The result is that you loose time information accuracy.regards
marcusTuesday, August 3, 2004, 10:34:18 AM, you wrote:
Hi
There's a library that i wrote that supports timestamps > 2037.
It takes advantage of the fact that PHP converts integers to floats on
overflow. It uses the nearly the same api asdate()
andmktime()
, to
make
porting easier.Regards, John
"Jevon Wright" jevon@jevon.org wrote in message
news:011601c47920$8d116ba0$0a00a8c0@home.jevon.org...I always wished that PHP had VB's set of operators on dates/times...
(and
also in SQL): year(), month(),date()
, time_serial(), and the like.
Yes,
you
can do it with date("...", $x); but then it's just awkward to remember
all
the operators.Also, I'd always wished that PHP would have support for dates after 32
bit
(2037)... when do you think Pecl's Date would get into PHP?Jevon
----- Original Message -----
From: "Jason Garber" jason@ionzoft.com
To: internals@lists.php.net
Sent: Tuesday, August 03, 2004 2:36 PM
Subject: [PHP-DEV] Date SupportHello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
Is there a particular reason that PHP does not have a really
good
set of functions for dealing with true date and time types (i.e.
not
timestamps)?I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools
for
handling dates. I think that this style of date handling, where
the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to
go.
Comments?If there is no good reason for not adding this set of functions
to the PHP core, what would be the method of designing an
acceptable
set of functions?PHP is a feature packed language, but it's strange that this does
not
exist in the core. Thanks for your time.--
Best regards,
Jason Garber mailto:jason@ionzoft.com
IonZoft, Inc.--
--
Best regards,
Marcus mailto:helly@php.net
--
Best regards,
Marcus mailto:helly@php.net
Also, I'd always wished that PHP would have support for dates after 32 bit
(2037)...
Funny my Athlon64 reports dates just fine up until 12/31/2147483647 (I
blame glibc for not going clear out to 0x7FFFFFFFFFFFFFFF -- silly signed
ints...)
-Sara
Hello internals,
Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.
- Is there a particular reason that PHP does not have a really good
set of functions for dealing with true date and time types (i.e. not
timestamps)?
I'm about 60% done with this ;-)
- I think that good date and time handling in PHP would be a
large plus. MySQL provides, imho, a very effective set of tools for
handling dates. I think that this style of date handling, where the
standard format was YYYY-MM-DD HH:MM:SS would be an ideal way to go.
Comments?
This is one format that I can parse... but the major format will be a
"timestamp" of some sort.
regards,
Derick