#44163 [NEW]: Addition of more useful date time functions

From: Date: Tue, 19 Feb 2008 05:05:55 +0000
Subject: #44163 [NEW]: Addition of more useful date time functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122442@lists.php.net to get a copy of this message
From: cool_lim_lp at yahoo dot com dot sg Operating system: any PHP version: 5.2.5 PHP Bug Type: Feature/Change Request Bug description: Addition of more useful date time functions Description: ------------ Is it possible to add more useful functions like date substraction and date addition and the ability to get individual date parts? For example, to get a date part, we have to do something like $datetime = new DateTime ('12 jan 2008'); $day = (int)$datetime->format('d'); We have to convert an internally stored int to a string and then back to an int again, duh. Why not simply introduce a 'getDay' function? $day = $datetime->getDay(); $year = $datetime->getYear(); Subtraction of two dates: First, we have to convert the datetime object to a UNIX timestamp, which has a very limited range and then perform some maths on this timestamp itself. It is very tedious and troublesome. for example to calculate the age of a person: $now = new DateTime ('now'); $dob = new DateTime ('19 jan 1955'); you have to first convert to a UNIX timestamp, but the dob is out of the range allowed. Or you could use date_parse to get some info and then perform some lengthy maths to calculate the age. Sometimes we also need to know the amount of time that has elapsed between two dates in terms of hours, minutes, seconds, years, or months etc. But currently, there is no easy way to calculate that using PHP 's built-in functions. -- Edit bug report at http://bugs.php.net/?id=44163&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44163&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44163&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44163&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44163&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44163&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44163&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44163&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44163&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44163&r=support Expected behavior: http://bugs.php.net/fix.php?id=44163&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44163&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44163&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44163&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44163&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44163&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44163&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44163&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44163&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44163&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44163&r=mysqlcfg

« previous php.bugs (#122442) next »