View Single Post
Old 02-07-2013, 06:09 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,645
Thanks: 4
Thanked 2,450 Times in 2,419 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
These are *not* datetime. These are strings and integers, don't mistake the two as the DateTime is an object type, not a scalar type.
This is your order of evaluation of relative versus non-relative formats:
PHP Code:
$constructed strtotime("2013-02-06 17:59:19");
$date date('Y:m:d H:i:s'$constructed);
$final=date('Y:m:d H:i:s',strtotime("$date + 5 weekdays"));
print 
$final PHP_EOL;// 2013:02:13 00:00:00 (which is correct for the criteria)

$final date('Y:m:d H:i:s'strtotime("+5 weekdays $date"));
print 
$final PHP_EOL// 2013:02:13 17:59:19 (which is correct for the criteria) 
Edit:
In hindsight, this may be a bug. The relative should always apply *after* the absolute, unless its 'yesterday', 'midnight', 'today', 'noon', or 'tomorrow'. So that says that the above should work in either order which it certainly does not appear to.
I'd simply use the DateTime myself:
PHP Code:
$dt = new DateTime('2013-02-06 17:59:19');
$dt->add(DateInterval::createFromDateString('+5 weekday'));
print 
$dt->format('F j Y H:i:s'); 
Which gives me 'February 13 2013, 17:59:19' as the result.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php

Last edited by Fou-Lu; 02-07-2013 at 06:29 PM..
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
nani_nisha06 (02-08-2013)