Code Snippets » PHP » Function, written in PHP, that returns the difference in minutes between two dates/times
Function, written in PHP, that returns the difference in minutes between two dates/times
Function that returns the difference in minutes between two dates/times.
<?php
/**
* Calculates the difference in minutes between two dates/times
* @param type $p_from_time Date/time less
* @param type $p_to_time Date/time greater than
* @return string Returns the difference in minutes
*/
function getTheDifferenceInMinutes($p_from_time, $p_to_time) {
// Set timezone
date_default_timezone_set('Europe/London');
$to_time = strtotime($p_to_time);
$from_time = strtotime($p_from_time);
return abs((int)(($to_time - $from_time) / 60));
}
?>
If our work has been of help, you can help us with a small donation...
Our programmers will thank you!
Related code snippets posted in
PHP:
The best
PHP
recommended books:
All information contained in this web site are the property of MdmSoft.
The information is provided "as is", MdmSoft will not be liable for any misuse of the code contained in these pages,
nor can it be for inaccuracies, grammatical errors or other factors that may have caused damage or lost earnings.
MdmSoft is not responsible for the content of comments posted by users.
The examples in this area have the educational and demonstration purposes only,
and may be copied only for your reference, but cannot be used for commercial purposes,
or for any other purpose, without the express written consent of MdmSoft.
MdmSoft also reserves the right to change, without notice, to your liking this web site,
the pages and its sections, and may suspend temporarily or definitely the various services included on this site.
While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.