Working with Dates beyond 2038 in PHP4/5

I've spent a lot of time searching the net in order to find a library that can be used as a replacement for the php strtotime() functions. I was looking for something that would at least allow me to convert dates like 2 Jan 2039 to a timestamp. My closest find was the ADODB Date library, which can be used to replace the other date functions (like mktime, etc) but not strtotime. As a result of this, I've decided to create me own little Date class library as a first start.
This Date Class library makes use of the ADODB Date library in order to support timestamps before 1970 and after 2038. Here's a short list of supported features:
- Supports both php4 and php5.
- Handles dates before and 1970 and afer 2038.
- Supports over four different date input formats.
- Compatible with existing php date functions (e.g date,strtotime,etc).
To start working with the Date class you will first need to download and extract the dateclass.zip file to a folder. Copy the files date.class.php and adodb_date.php to a folder on your website or application. You will only need to include the file date.class.php inside your PHP page.
Note: The ADODB Date Library is a standalone library and can easily updated when a new version is available from the ADODB website. This file is only included for convenience.
Example:include_once "/includes/date.class.php"; $date = new Date("March 20, 2039 11:30 PM"); echo $date->format("d-M-Y");
You can also use the format() function to directly format date value that's passed in as the second parameter.
Example:$date = new Date(); echo $date->format("M d, Y","2079/12/20 12:30:23");
| MM/DD/YYYY | MM-DD-YYYY | MM.DD.YYYY |
| DD/MM/YYYY | DD-MM-YYYY | DD.MM.YYYY |
| YYYY/MM/DD | YYYY-MM-DD | YYYY.MM.DD |
| MMM DD, YYYY | DD MMM YYYY | DD MMM YYYY HH:NN:SS AM/PM |
Links:
For more information about the ADODB Date library please visit the ADDB Date Library website.
The Date class library is licensed under the LGPL. You're free to use and improve where necessary. I gladly welcome your feedack, suggestions and ideas. You may post your comments below.
Write a comment
- Required fields are marked with *.
Posts: 7
Reply #6 on : Thu July 10, 2008, 17:24:21
Posts: 7
Reply #5 on : Mon June 30, 2008, 16:45:35
Posts: 7
Reply #4 on : Mon June 02, 2008, 21:19:04
Posts: 7
Reply #3 on : Wed May 21, 2008, 14:34:15
Posts: 7
Reply #2 on : Mon May 05, 2008, 23:41:08
Posts: 7
Reply #1 on : Wed April 16, 2008, 07:38:42
Subscribe to Feed by Email
Posts: 7
Reply #7 on : Tue July 15, 2008, 03:26:19