note 91450 added to class.datetime

From: Date: Wed, 10 Jun 2009 15:00:18 +0000
Subject: note 91450 added to class.datetime
Groups: php.notes 
Request: Send a blank email to php-notes+get-156743@lists.php.net to get a copy of this message
If you're stuck on a PHP 5.1 system (unfortunately one of my clients is on a rather horrible webhost who claims they cannot upgrade php) you can use this as a quick workaround: <?php if (!class_exists('DateTime')) { class DateTime { public $date; public function __construct($date) { $this->date = strtotime($date); } public function setTimeZone($timezone) { return; } private function __getDate() { return date(DATE_ATOM, $this->date); } public function modify($multiplier) { $this->date = strtotime($this->__getDate() . ' ' . $multiplier); } public function format($format) { return date($format, $this->date); } } } ?> it is NOT perfect. Timezones and DST are not supported, but if you just need compatible basic functions this works. Feel free to complete this so it's compatible with the 5.2 datetime object. ---- Server IP: 64.71.164.2 Probable Submitter: 195.149.46.150 ---- Manual Page -- http://www.php.net/manual/en/class.datetime.php Edit -- https://master.php.net/note/edit/91450 Del: integrated -- https://master.php.net/note/delete/91450/integrated Del: useless -- https://master.php.net/note/delete/91450/useless Del: bad code -- https://master.php.net/note/delete/91450/bad+code Del: spam -- https://master.php.net/note/delete/91450/spam Del: non-english -- https://master.php.net/note/delete/91450/non-english Del: in docs -- https://master.php.net/note/delete/91450/in+docs Del: other reasons-- https://master.php.net/note/delete/91450 Reject -- https://master.php.net/note/reject/91450 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#156743) next »