$startdate_time='13-05-2023 9:00';
$enddate_time='13-05-2023 9:30';
$start_timestamp=strtotime($startdate_time);
$end_timestamp=strtotime($enddate_time);
$minutes_diff= round(abs($end_timestamp- $start_timestamp) / 60,2);
echo $minutes_diff. " minutes ";
Output : 30 minutes
Category: user_questions
#How to add constraint foreign key in postgresql
How can I remove a specific item from an array using JavaScript ?
There are two main approaches
- splice()
- delete
splice() : splice is the most conman approaches remove a specific item from
an array using JavaScript
syntax : MyArray.splice(index, 1);
let country = ['USA', 'UK', 'UAE', 'India']
let removed = country.splice(2, 1);
Result : ['USA', 'UK', 'India']
delete : Delete is second way to remove an item from an array in JavaScript,
syntax: delete MyArray[index]
let country1 = ['USA', 'UK', 'UAE', 'India']
let removed = delete country1[2]
Result : ['USA', 'UK', undefined , 'India']
Better to use splice() it is simple way to remove a specific item from an array using
JavaScript , when you use delete for an array you could get wrong results
for MyArray.length
Here
country1.length = 4
country.length = 3