How to add month in current date using Php

This is useful when you are playing with date and time.This is very short solution for it.

Below example is showing how to add 1 month in current date.

Suppose current date is 2016-05-25 10:33:19 and new date should be 2016-06-25 10:33:19


$today = date("Y-m-d h:i:s");// current date
$datemonth = strtotime(date("Y-m-d h:i:s", strtotime($today)) . "+1 month"); 
$after_month = date('Y-m-d h:i:s', $datemonth);
Advertisements

How To Speed Up WordPress

As a side note, these are not ordered by importance or any criteria, I’ve just gathered everything I’ve learned about speeding up page loads on WordPress and compiled them here.

I guarantee that using even a few will help speed up your site.

1. Choose a good host
2. Start with a solid framework/theme
3. Use an effective caching plugin
4. Use a content delivery network (CDN)
5. Optimize images (automatically)
6. Optimize your homepage to load quickly
7. Optimize your WordPress database
8. Disable hotlinking and leeching of your content
9. Add an expires header to static resources
10. Adjust Gravatar images
11. Add LazyLoad to your images
12. Control the amount of post revisions stored
13. Turn off pingbacks and trackbacks
14. Replace PHP with static HTML, when necessary
15. Use CloudFlare

Using PHP Copy to move files from server to server.

You can just create a php file in the destination server and load the file once in your browser. For example you add this code in http://destination-url/copy-files.php and in copy-files.php you add this php code:

     /*

  Transfer Files Server to Server using PHP Copy

*/

 

/* Source File URL */

$remote_file_url =http://origin-server-url/files.zip”

 

/* New file name and path for this file */

$local_file =files.zip”;

/* Copy the file from source url to server */

$copy = copy( $remote_file_url, $local_file );

/* Add notice for success/failure */

if( !$copy ) {

    echo “Doh! failed to copy $file…\n”;

}

else{

    echo “WOOT! success to copy $file…\n”;

}

How to send email using PHPMailer

First, download PHPMailer using the direct link below:

PHPMailer_5.2.0.zip

After you have downloaded the file, unzip and extract it to your public_html. After unzipping the file we have public_html/PHPMailer_5.2.0. Next you will need to edit your web pages to use the PHPMailer code.

Add the PHPMailer code to your site:

<?php
require("class.PHPMailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mail.hostname.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "USERNAME"; // SMTP username
$mail->Password = "PASSWORD"; // SMTP password

$mail->From = "from@example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("josh@example.net", "Josh Adams");
$mail->AddAddress("ellen@example.com"); // name is optional
$mail->AddReplyTo("info@example.com", "Information");

$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
?>