Posts by deepak:
Find number of weekdays (Mon, Tues etc) between two dates
<?php
function workingDays( $fromDate, $interval ) {
$date_array = explode(‘-’, $fromDate );
$day = $date_array[0];
$month = $date_array[1];
$year = $date_array[2];
$working_date = array();
for ( $i = 1; $i <= $interval; $i++ ) {
$working_date[] = date(“l”, mktime(0, 0, 0,$month,$day +(int)$i,$year));
}
return $working_date;
}
$getDays = workingDays(’30-11-2011′, 30 );
str_replace(array(‘Friday’),array(‘Friday’) ,$getDays, $dupweekDays); // trick to check the occurrence of week days
echo $dupweekDays;
?>
Explanation of the above code:
$getWorkingDays = workingDays(’30-11-2011′, 30 );
W call the workingDays function it accept two prams a) the start date 2) the number of days between to dates
This function will return the name of weekdays i.e Monday, Tuesday,Wednesday , Thursday , Friday , Saturday , Sunday
——————————————————————————————————————————————————————————————————————-Below is str_replace(array(‘Friday’) , array(‘Friday’) ,$getDays, $dupweekDays); // trick to check the occurrence of week days
echo $dupweekDays;
the login to find the repeating days so we we need to find number of Mondays then we need to replace the first and second parameter of str_replace function with array(‘Monday’)
The $dupweekDays will the variable having the count of repeating Mondays
Facebook Connect (Graph API) in cake php
To implement Facebook connect using graph API you need to follow the steps 1) Extract the facebook_core_files.zip file and put all of them in vendors folder of cake php 2) In your apps controller include this code at the top of the file App::import(‘Vendor’, ‘facebook’, array(‘file’ => ‘facebook.php’)); 3) in your apps controller add this [...]



