I've been using php for about 5 months now. One of the first things I noticed it was missing was a standard in-built manner of handling dates. I assumed that, being inexperienced, I was probably missing something and in time all would become clear.

It's a while later now and I still think it sucks that it doesn't have a standard date variable type.

Why doesn't it have 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.).

Dates could be stored 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.

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, it will only work on dates between 1970 and 2038. Hmmm. Nice one, Bill (are we in for another 'new millenium' problem on windows machines in 2038?).

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


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

PSS Technical note:

As you all know, internally the only rational way to store dates is as a sequential number from an chosen starting date - eg. 1-1-1960, 1-1-1970, whatever. Prior dates are simply stored as negative numbers.
. Ross Honniball. JCU Bookshop Cairns, Qld, Australia.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to