Category: PHP Development

PHP Development

How to send SMS using PHP

In this tutorial, we have explained how to send SMS using PHP. There are many SMS API service providers like Twilio, Nexmo, MSG91, Text local that you can use to send SMS using the PHP programming language. In this tutorial we learned how to send SMS using twilio API service provider. Twilio’s APIs (Application Programming Interfaces) power its platform for communications. Behind these APIs is a software layer connecting and optimizing communications networks around the world to allow your users to call and message anyone, globally. Twilio has a whole host of APIs, from SMS to Voice to Wireless! Step 1: Register for Twilio account Sign Up for free twilio account from here :  Step 2: Verify Phone Number Next, we need to create a phone number for your account from which you can send the SMS Click -> “Phone Numbers” in the sidebarClick -> “Get a number now” link to generate your own phone numberNow “Click -> Get your first Twilio phone number”.Once you click “Get your first Twilio phone number”, a new pop-up window will show your Twilio Phone Number. Now, click “Choose this Number”. Step 3: Create API Credentials Next, you need to get your account SID and your authorization token.On the Console Dashboard page you can get your credentials. Step 4: Install PHP SDK The method of installing the SDK is via composer
composer require twilio/sdk
The another method of installing the SDK without composer is possible to download and use the PHP SDK manually and unzip SDK folder into your project directory. You can download from here. Step 7: Create Integration

require __DIR__ . '/vendor/autoload.php'; //with composer
// based on where you downloaded and unzipped the SDK
require __DIR__ . '/twilio-php-main/src/Twilio/autoload.php'; //without composer
use Twilio\Rest\Client;

// Your Account SID and Auth Token from
$auth_token = 'your_auth_token';

// In production, these should be environment variables. E.g.:
// $auth_token = $_ENV["TWILIO_AUTH_TOKEN"]

// A Twilio number you own with SMS capabilities
$twilio_number = "+15558675309";

$client = new Client($account_sid, $auth_token);
    // Where to send a text message (your cell phone?)
        'from' => $twilio_number,
        'body' => 'My first trial SMS!'
Step 5: Receiving a SMS Here you go! Note: Trial accounts cannot send messages to unverified numbers; verify +9198XXX42887 at, or purchase a Twilio number to send messages to unverified numbers. Conclusion: I hope this tutorial helpful for you, if you have any issue with integration, please comment below. Thank You!
PHP Development

Dynamic Timezone : Same Time in Different Countries

In this tutorial we have explained how to create dynamic time zone which shows same time for different countries. You can use this feature for your online schedules to provide time to all users according to their country time.
<script type="text/javascript">

function dynamicTimeChange(timezone){

let date = new Date(Date.UTC(0, 0, 0, 13, 0, 0));
SlotTime = date.toLocaleString("en-US", {timeZone: timezone, hour: '2-digit', minute:'2-digit'});

document.getElementById("dynamictzDiv").innerHTML = SlotTime;
<label style="text-align: center;font-size: initial;">Select Your Timezone</label>
function select_Timezone($selected = '') {

// Create a list of timezone
$OptionsArray = timezone_identifiers_list();
$select= '<select name="SelectContacts" onchange="dynamicTimeChange(this.value);" id="selectTime" style="width: 120px;font-family: FontAwesome;">
<option disabled selected>
Please Select Timezone
<option value="Canada/Pacific">Canada/Pacific Standard Time</option>
<option value="Canada/Atlantic">Canada/Atlantic Standard Time</option>
<option value="Australia/West">Australian Central Western Standard Time&amp;lt;/option&amp;gt;
<option value="Australia/Queensland">Australia/Australian Eastern Standard Time</option>';

return $select;
echo select_Timezone() . '<br>';
<div class="timeDivPremiumSch" style="margin-top: 12px;">

<label id="dynamictzDiv">05:00 AM</label>

Output: You can add Timezones in select list according to your needs. When you change the timezone from select dropdown list, it will change the time of label which is currently “05:00 AM” and display new time of your selected time. Here, I used “05:00 AM” as a static time so in this we can find your timezone’s “05:00 AM” of any other timezone. Date.UTC(0, 0, 0, 13, 0, 0) here, ’13’ is describing hour, you can add as your static time it will must be between 0-24. Conclusion: I hope this tutorial helpful for you, if you have any issue with this, please comment below. Thank You!