Re: Need for Date-object
| From: | Manuel Lemos | Date: | Tue, 17 Jul 2001 17:32:48 +0000 |
| Subject: | Re: Need for Date-object | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-840@lists.php.net to get a copy of this message | ||
Hello,
Erik Hjortsberg wrote:
>
> I always find it a hassle to use date and time data in my php applications.
> One have to convert and parse between mktime() and date() and have to keep
> track of different parameters and different formats.
> This is due to php absent handling of atomic dates, ie. objects. Treating
> them as strings is not very efficient code-wise.
I don't quite agree. You can use the ISO-8601 format (YYYY-MM-DD
HH:MM:SS) and you can do a lot of operations without converting to
integers. For instance, you can use strcmp() to compare two dates and it
will tell you if they are equal or which of them is older.
Using integers has it downside because if you use some of available PHP
functions you are limited to ranges between 1970 and 2038 on 32 bit
OSes.
> I've used some date-classes I've done myself, but it is clear that all
> would benefit from a standardized way of handling dates. And I think if
> would fit perfectly into what PEAR is about if we could provide a solid
> date-class.
> Now, I know that there's already a Date_Date class, but that consists
> solely of static functions and cannot be used to provide atomic date-objects.
> Furthermore, this is something that's already been tackled by all major
> object-capable languages. So there's no need to reinvent the wheel.
> So I ask all of you, given experiences from other languages, what interface
> and functions would you wan't to see in a common date-object?
I don't know what you are looking for, but maybe you want to look into
this class that eases the manipulation of dates in forms, by generated
locale sensitive input fields for forms setting and retrieving date time
values.
http://phpclasses.UpperDesign.com/browse.html/package/230
Manuel Lemos