FAQ
Hello internals,

Not to take away from the wonderful and lively "GOTO" discussion,
but... I've got a couple simple questions.

1. 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)?

2. 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?

3. 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.

Search Discussions

  • George Schlossnagle at Aug 3, 2004 at 2:41 am

    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.
    What's insufficient in strtotime() and strftime()?

    George
  • Jason Garber at Aug 3, 2004 at 3:08 am
    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
  • Robert Amos at Aug 3, 2004 at 3:19 am

    On Mon, 2 Aug 2004 23:08:17 -0400, Jason Garber wrote:
    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
  • Derick Rethans at Aug 3, 2004 at 7:32 am
    On Mon, 2 Aug 2004, George Schlossnagle wrote:
    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.
    What's insufficient in strtotime() and strftime()?
    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
  • Wez Furlong at Aug 3, 2004 at 2:41 am
    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.
    On Mon, 2 Aug 2004 22:36:14 -0400, Jason Garber wrote:
    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Jason Garber at Aug 3, 2004 at 3:07 am
    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 wrote:
    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Wez Furlong at Aug 3, 2004 at 3:30 am
    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.
    On Mon, 2 Aug 2004 23:07:49 -0400, Jason Garber wrote:
    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 wrote:
    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Joseph Lee at Aug 3, 2004 at 7:09 am
    http://pear.php.net/package/Date/docs/1.4.2/

    -----Original Message-----
    From: Jason Garber
    Sent: 03 August 2004 04:08
    To: internals@lists.php.net
    Subject: Re: [PHP-DEV] Date Support


    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. Maybe in
    WF> a future release...

    WF> --Wez.

    WF> On Mon, 2 Aug 2004 22:36:14 -0400, Jason Garber <jason@ionzoft.com>
    WF> wrote:
    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Jevon Wright at Aug 3, 2004 at 6:07 am
    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.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Derick Rethans at Aug 3, 2004 at 7:34 am

    On Tue, 3 Aug 2004, Jevon Wright wrote:

    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
  • John Lim at Aug 3, 2004 at 8:34 am
    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 Support

    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php
  • Marcus Boerger at Aug 3, 2004 at 8:45 am
    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 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 Support

    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php



    --
    Best regards,
    Marcus mailto:helly@php.net
  • John Lim at Aug 3, 2004 at 9:32 am
    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
    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 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 Support

    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php



    --
    Best regards,
    Marcus mailto:helly@php.net
  • Marcus Boerger at Aug 3, 2004 at 9:55 am
    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() 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
    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 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 Support

    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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)?

    2. 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?

    3. 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.

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php



    --
    Best regards,
    Marcus mailto:helly@php.net



    --
    Best regards,
    Marcus mailto:helly@php.net
  • Sara Golemon at Aug 3, 2004 at 7:08 pm

    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
  • Derick Rethans at Aug 3, 2004 at 7:32 am

    On Mon, 2 Aug 2004, Jason Garber wrote:

    Hello internals,

    Not to take away from the wonderful and lively "GOTO" discussion,
    but... I've got a couple simple questions.

    1. 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 ;-)
    2. 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedAug 3, '04 at 2:36a
activeAug 3, '04 at 7:08p
posts17
users10
websitephp.net

People

Translate

site design / logo © 2022 Grokbase