note 101983 modified in function.date-sub by danbrown

From: Date: Fri, 21 Jan 2011 15:28:50 +0000
Subject: note 101983 modified in function.date-sub by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175966@lists.php.net to get a copy of this message
You cannot replace date_sub('2000-01-20') by DateTime::sub('2000-01-20') because DateTime::sub is not static. You have to create the DateTime object first. Example: <?php $dateA = date_sub('2000-01-20', date_interval_create_from_date_string('10 days')); ?> will be replace by <?php $dateB = new DateTime('2000-01-20'); $dateA = $dateB->sub(date_interval_create_from_date_string('10 days')); ?> --was-- You cannot replace date_sub('2000-01-20') by DateTime::sub('2000-01-20') because DateTime::sub is not static. You have to create the DateTime object first. Example: $dateA = date_sub('2000-01-20', date_interval_create_from_date_string('10 days')); will be replace by $dateB = new DateTime('2000-01-20'); $dateA = $dateB->sub(date_interval_create_from_date_string('10 days')); http://php.net/manual/en/function.date-sub.php

« previous php.notes (#175966) next »