Forum Moderators: coopster

Message Too Old, No Replies

New data and time APIs coming in PHP6

PECL package available now for PHP5

         

coopster

5:04 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I happened to notice a User Defined comment from Aidan (maintainer of the User Notes at PHP) today on the time() [php.net] function page ...


PHP 6 will be shipping a new inbuilt date and timestamp manipulation API. It's available on PECL here:
[pecl.php.net...]

I pulled the package down just to check a couple things out. Seems like it is going to be a nice set of functions. Granted, for any of us that have been doing development in PHP for any given period of time we probably all have our own classes or functions that we've built, but now it's going to be built-in (starting at PHP6 at least, by the looks of it).

Here are a couple of comment notes from the code:


Date is a collection of functions and classes to deal with dates. 
Support for date outside the UNIX date limitations. It provides
a lot of convenience functions/methods.

DATES RANGE SUPPORT 
-------------------

Year 1 to around 32000. Sorry to do not be too much precise for now :). 
To be honest it works with years before year 1, but a bit too hasardous imo.
I may add it year<0 in next versions.

EASTER DATES 
------------

<date_get_easter> use the ecclesiastical calendar. If you like to get the 
orthodox ecclesiastical calendar, use date_get_orthodox_easter.

informations about easter dates calculation:

[smart.net...]
[smart.net...]

WEEK NUMBERS 
------------

Take care about the different weeknumbers function. 
get_week_year (Date:getWeekOfYear) returns the "human" week of year
get_isoweek_of_year returns the ISO8601 week of year

Algorithm for the ISO8601 described here:

[personal.ecu.edu...]

I noticed the TODO list also includes a request to add a Calendar class. Altogether, it looks like a nice feature set to be built-in.

lupatis

5:34 pm on Oct 27, 2005 (gmt 0)

10+ Year Member



Hi Coopster,

I wish these where available when I started with PHP - some of the hacks/methods for date conversion I have employed are ..... interesting to say the least ;-)

It never ceases to amaze me the speed that PHP develops.

Mike

coopster

8:35 pm on Oct 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Oh I'm sure. I've developed a few different functions and classes in this area as well. As I said, I'll bet most of us have.

That's usually how the best stuff gets back in when you're dealing with open source, though. Contributions from programmers that are using the software and offer their time and effort for enhancements like this. Some of the stuff looks quite promising in this one.

By the way, welcome to WebmasterWorld, lupatis.

g1smd

3:44 pm on Oct 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The ISO 8601 week number sometimes sees the last few days of a year being counted as belonging to the next year, or else the first few days of a year as belonging to the previous year.

Some previous implementations of this functionality have been buggy.

This time, 2006-01-01 corresponds to 2005-W52-D7 for example.

It follows that 2006-W01-D1 is therefore on 2006-01-02.