Monthly Archives: August 2017

Generate a random password like Numbers,characters, special characters in PHP

Hi all,

In this tutorial,we will discuss how to generate random passwords using php functions. This applications is widely used in web application for registration purpose. The auto password is very helpful, and the hacker can’t easy to access our password because it include characters(a-z and A-Z), numbers(0-9) and special characters(!@#$%^&*()-=+?.).

The random password used for we application for users for security. And also we can specify the length of the password and these generated password can insert to database. For security we can insert the password to database using encryption method like sha1 or md5. Using PHP, it’s pretty easy to generate a random password.

We use str_shuffle function use for combine characters, numbers and special characters for generationgpassword. This function helps to randomly shuffles all the characters of a string.

Example





If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Print all second saturday,fourth saturday and sunday between two date using php

Hi guys!
In previous article we discuss how to Calculate the number of Second Saturady, Fourth Saturday and Sunday Between Two dates in PHPIn this article share how to print or display the second saturday,fourth saturday and all sunday between two date range unsing php.

Consider from date and two date for performing this operations. The output is may be one element or more than one element. So we using the array for storing and printing the result.

Some important tips or points are used for finding the solutions. They are:

  • Calculating the week number for a given date – PHP
  • Day of the Date
  • Print second saturday, fourth saturdayand all sunday

Based on the above steps or points we can reach the solution. Because, we get the day of the date then we get the day is sunday or saturday. After that we can find day of the week. If the week is 2 then we can say it’s second week the we can find the second saturday.If the week is 4 then we can find the fourth saturday. And also we can find all sundays.




Calculating the week number for a given date – PHP

Getting the week number of given date in month using php. It’s very simple and useful for finding the second or fourth week between two date range. Its very useful for fetching all second saturday or fourth saturday from calender.

		

In the above code the output is:4. 22nd august is fourth week of 2017.

Day of the Date -PHP

The day of the date in php is check the date of the day. We can print all the day, between two date.

format('l');
	echo $daydate;
?>




The output of the above code is:Thursday.

Print second saturday, fourth saturdayand all sunday

Fetch all second saturday,fourth saturday and all sunday between two date using pure php. Its very simple, because we get the day of the date, and also week of the date. If the week is 2 and day is saturday then we get the second saturday. Based on this method we get fouth saturday, sunday between the two date range.

Full Code

format('l');
		if($daydate=='Sunday')
		{
			$daydate= 0;
		}
		else if($daydate=='Monday')
		{	
			$daydate= 1;
		}
		else if($daydate=='Tuesday')
		{
			$daydate= 2;
		}
		else if($daydate=='Wednesday')
		{
			$daydate=3;
        }	
		else if($daydate=='Thursday')
		{
			$daydate= 4;
		}
		else if($daydate=='Friday')
		{
			$daydate=5;
        }			
		else
		{
			$daydate= 6;
		}
		if ($week_day == 2) 
		{
			if ($daydate == 6)
			{
				$total++;
				$date_details=date("Y-m-d",$j);
			$e2=array();
			$e2['title']='Second Saturday ';
			$e2['start']=$date_details;
			array_push($events,$e2);	 
			}
		}
		if($week_day == 4)
		{
			if ($daydate == 6)
			{
				$total++;
				$date_details=date("Y-m-d",$j);
				$e3=array();
				$e3['title']='Fourth Saturday ';
				$e3['start']=$date_details;
				array_push($events,$e3);
			}
		}		
		if ($daydate == 0)
		{
			$total++;
			$date_details=date("Y-m-d",$j);
			$e4=array();
			$e4['title']='Sunday';
			$e4['start']=$date_details;
			array_push($events,$e4);
		}
	}
	echo 'total second saturday fourth saturday and sunday:'.$total; 
	echo '

'; echo json_encode($events); ?>

The output is:





total second saturday fourth saturday and sunday:10
[{“title”:”Second Saturday “,”start”:”2017-07-08″},{“title”:”Sunday”,”start”:”2017-07-09″},{“title”:”Sunday”,”start”:”2017-07-16″},{“title”:”Fourth Saturday “,”start”:”2017-07-22″},{“title”:”Sunday”,”start”:”2017-07-23″},{“title”:”Sunday”,”start”:”2017-07-30″},{“title”:”Sunday”,”start”:”2017-08-06″},{“title”:”Second Saturday “,”start”:”2017-08-12″},{“title”:”Sunday”,”start”:”2017-08-13″},{“title”:”Sunday”,”start”:”2017-08-20″}]

If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

Calculate the number of Second Saturady, Fourth Saturday and Sunday Between Two dates in PHP

Good Morning to all,
Today we focus how to calculate number of second saturday,fourth saturday and sunday between two dates.In javascript,it’s very easy to develope this application. But in php, many users have no knowledge regarding this application or this problem.

Here I explain,how to solve this problem: count the number of second saturday, fourth saturday,all sunday between two date using php. Its very simple and easy to understand.




";
		$startdate = strtotime("+2 week", $startdate);
		$total++;
		
	}
	for($j=$from_date;$j<=$to_date;$j+=86400)
		{	
			if(date('w',($j)) ==0)
			{
				$total++;
			}
		}
	echo $total;
?>

First we consider two date and store to variable for develope application like from date and to date. In the above example the fromdate is 2017-08-11 and to date is 2017-09-22. Next we create one variable total for counting number of second,fourth saturday and all sunday betweeen the date. The strtotime is one of the important function in php date.This is used to convert an English textual datetime description to a UNIX timestamp.




If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.