View Single Post
Old 02-08-2013, 10:19 AM   PM User | #3
nani_nisha06
Regular Coder

 
Join Date: Oct 2012
Location: mother land --india
Posts: 159
Thanks: 37
Thanked 2 Times in 2 Posts
nani_nisha06 is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
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.
Fou-Lu,

One thing I don't understand below comments can you brief.

Code:
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.
nani_nisha06 is offline   Reply With Quote