Solved

Count time in PHP

Posted on 2001-08-21
1
1,030 Views
Last Modified: 2010-05-18
How can we count the different time  in PHP :

$time1="09/05/2001 17:59:54"
$time2="10/05/2001 18:59:54"

The result will
$time=$time2 - $time1 = "1 day 1h 0' 0'' "
0
Comment
Question by:amara_78456
1 Comment
 
LVL 4

Accepted Solution

by:
heddesheimer earned 10 total points
Comment Utility
<?
$time1 = mktime(17, 59, 54, 5, 9, 2001);
$time2 = mktime(18, 59, 54, 5, 10, 2001);
$diff = $time2 - $time1;
echo "difference: " . $diff . " seconds<br>\n";
$days = floor($diff / (3600 * 24));
$diff -= $days * (3600 * 24);
$hours = floor($diff / 3600);
$diff -= $hours * 3600;
$minutes = floor($diff / 60);
$seconds = $diff - ($minutes * 60);

echo "diff is: $days days, $hours hours, $minutes minutes and $seconds seconds<br>\n";

?>
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now