note 55593 added to ref.datetime

From: Date: Mon, 08 Aug 2005 14:50:40 +0000
Subject: note 55593 added to ref.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-93248@lists.php.net to get a copy of this message
To easily circument the silly pre-1970 and post-2037 restrictions of shortsighted PHP in date(), mktime() and strtotime(), you can find somebody's birthday or other date in the past, if born before 1970, like this: // example birthdate - my dad's $birthdate="1951-06-09"; // birthdate is before 1970 if($birthdate<'1970-01-01'){ // break pieces apart $birthdate=explode("-",$birthdate); // piece together formatted date based on year 2037 - this will find month and day $birthdate=date("F j",strtotime("2037-$birthdate[1]-$birthdate[2]")) . ", $birthdate[0]"; // note that actual birthdate is appended to the end // birthdate 1970 and upwards, format normally }else{ $birthdate=date("F j, Y",strtotime($birthdate)); } ---- Manual Page -- http://www.php.net/manual/en/ref.datetime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55593 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55593&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55593&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93248) next »