For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > May 2004 > Why doesn't php have a 'date' variable type?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why doesn't php have a 'date' variable type?
Ross Honniball

2004-05-20, 5:30 am

I accidently sent this to php-db mailing list earlier today. Apologies to
people who get it twice.

Why doesn't php offer a standard class or variable type to help process
dates in a standard manner?

Php should offer a DATE variable type (in addition to string, int, array,
object etc.).

Date variables could be created by utilising standard date functions. eg.

$birthday = SetDate('23-07-1985', 'dmy');

Use of this function would effectively declare $birthday as a field of type
date. (note that I wish this was my birthday).

Standard maths could be performed on date fields for comparison. eg.

$newdate = $start_date + $birthdate - 5; // as in days

if ($date1 < $date2) ..whatever..;

And of course standard routines for formating dates, standard routines for
showing time between dates / times etc. would all understand the date
variable type.

This frustrated me so much that I recently wrote a class to emulate, as
best as possible, this level of functionality, which would actually be
quite adequate if Windows didn't suck. But due to some lunatic Windows
limitation, the php DATE() funciton will only work on dates between 1970
and 2038. Annoying.

Anyway, am I missing something, or do other people find this a glaring
omission in an otherwise spiffing product?

Ross

PS note that in refering to dates above, I really mean date + time.

.. Ross Honniball JCU Bookshop Cairns Supervisor
.. James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
.. Ph:07.4042.1157 Fx:07.4042.1158 Em:ross@bookshop.jcu.edu.au
.. There are no problems. Only solutions.
\Walter

2004-05-20, 12:31 pm

PEAR:Date

Walter


"Ross Honniball" <ross@bookshop.jcu.edu.au> wrote in message
news:6.0.0.22.1.20040520183040.01ca2ea8@bookshop2.jcu.edu.au...
> I accidently sent this to php-db mailing list earlier today. Apologies to
> people who get it twice.
>
> Why doesn't php offer a standard class or variable type to help process
> dates in a standard manner?
>
> Php should offer a DATE variable type (in addition to string, int, array,
> object etc.).
>
> Date variables could be created by utilising standard date functions. eg.
>
> $birthday = SetDate('23-07-1985', 'dmy');
>
> Use of this function would effectively declare $birthday as a field of

type
> date. (note that I wish this was my birthday).
>
> Standard maths could be performed on date fields for comparison. eg.
>
> $newdate = $start_date + $birthdate - 5; // as in days
>
> if ($date1 < $date2) ..whatever..;
>
> And of course standard routines for formating dates, standard routines for
> showing time between dates / times etc. would all understand the date
> variable type.
>
> This frustrated me so much that I recently wrote a class to emulate, as
> best as possible, this level of functionality, which would actually be
> quite adequate if Windows didn't suck. But due to some lunatic Windows
> limitation, the php DATE() funciton will only work on dates between 1970
> and 2038. Annoying.
>
> Anyway, am I missing something, or do other people find this a glaring
> omission in an otherwise spiffing product?
>
> Ross
>
> PS note that in refering to dates above, I really mean date + time.
>
> . Ross Honniball JCU Bookshop Cairns Supervisor
> . James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
> . Ph:07.4042.1157 Fx:07.4042.1158 Em:ross@bookshop.jcu.edu.au
> . There are no problems. Only solutions.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com