Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Date range question -


if have 2 dates, 21/05/2010 , 23/05/2010, how can find out if 22/05/2006 7:16 am exists in between them?

i using following code calculate min/max date , select records in table clear update them.

    $today = date('l');      if($today == 'wednesday'){         $min = date('d/m/y', strtotime('0 days'));         $max = date('d/m/y', strtotime('+6 days'));     }else if($today == 'thursday'){         $min = date('d/m/y', strtotime('-1 days'));         $max = date('d/m/y', strtotime('+5 days'));     }else if($today == 'friday'){         $min = date('d/m/y', strtotime('-2 days'));         $max = date('d/m/y', strtotime('+4 days'));     }else if($today == 'saturday'){         $min = date('d/m/y', strtotime('-3 days'));         $max = date('d/m/y', strtotime('+3 days'));     }else if($today == 'sunday'){         $min = date('d/m/y', strtotime('-4 days'));         $max = date('d/m/y', strtotime('+2 days'));     }else if($today == 'monday'){         $min = date('d/m/y', strtotime('-5 days'));         $max = date('d/m/y', strtotime('+1 days'));     }else if($today == 'tuesday'){         $min = date('d/m/y', strtotime('-6 days'));         $max = date('d/m/y', strtotime('0 days'));     } 

datetime::diff

create datetime::diff between 21/05/2010 , 22/05/2006 7:16 am, datetime::diff between 23/05/2010 , 22/05/2006 7:16 am.

then check first datetime::diff > 0, , second < 0

update : used datetime::createfromformat, php5.3 method

update2 : tested code sample. produces expected output.

<?php $datetime_lower = datetime::createfromformat('d/m/y', '21/05/2010'); $datetime_upper = datetime::createfromformat('d/m/y', '23/05/2010'); $datetime_compare = datetime::createfromformat('d/m/y g:i a', '22/05/2006 7:16 am');  var_dump($datetime_lower < $datetime_compare); var_dump($datetime_upper > $datetime_compare);  if ($datetime_lower < $datetime_compare && $datetime_upper > $datetime_compare) {     echo " + date between"; } else {     echo " date not between"; } 

also, there procedural date_diff function


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -