Outsource ECommerce Development Company
In today’s competitive digital landscape, having a strong online presence is vital for businesses of all sizes. ECommerce websites are the backbone of modern retail, providing companies with a p
Read More
We are going to explain how to get the time difference between timeslots. below are the simple example given to get the time difference between the two given slots. As you can see we have used the inbuilt function DateTime::createFromFormat() or strtotime() of PHP to parse the time string according to the required format it returns the result.
Below are the simple example in PHP to get the time diffrence between time slots
<?php
function checkIfExist($fromTime, $toTime, $input) {
$fromDateTime = DateTime::createFromFormat("!H:i", $fromTime);
$toDateTime = DateTime::createFromFormat('!H:i', $toTime);
$inputDateTime= DateTime::createFromFormat('!H:i', $input);
if ($fromDateTime> $toDateTime) $toDateTime->modify('+1 day');
return ($fromDateTime <= $inputDateTime&& $inputDateTime<= $toDateTime) || ($fromDateTime <= $inputDateTime->modify('+1 day') && $inputDateTime<= $toDateTime);
}
$result=checkIfExist("08:00","18:00","09:00");
echo $result; // Result 1 - true
?>
The second possible way to get the time difference between time slots below are the given sample
Getting the time difference between two time slots in PHP, You can use strtotime() for time calculation. Based on your requirement you can customize the script.
Here is another simple example in PHP to get the time difference between time slots:
<?php
$checkTime = strtotime('09:00:59');
echo 'Check Time : date('H:i:s');
echo strtotime('2013-03-30 21:00') - strtotime('2013-03-29 21:00');
echo strtotime('2013-03-31 21:00') - strtotime('2013-03-30 21:00');
//Result you get 86400 and 82800.
?>
In today’s competitive digital landscape, having a strong online presence is vital for businesses of all sizes. ECommerce websites are the backbone of modern retail, providing companies with a p
Read MoreAssemble your own Marketplace today like Amazon, eBay, Souq style retail Online Shopping Store. Web-based business is the quickest developing retail advertise in Asia, Europe, the Americas, and around
Read MoreCloud innovation is wherever in this digitalized world. In organizations, cloud innovation offers its advantages to the clients just as to the proprietors. Accordingly, cloud innovation exists in the
Read More