|
|
|
When I try to get the difference between two times in hours to maka a total project time.
It is a modified example of
http://www.weberdev.com/get_example-3307.html
| <?php
function timeDiffH($firstTime,$lastTime,$dayFlag=false)
{
// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);
// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;
$mis = 60;
$his = $mis * 60;
$dis = $his * 24;
if($dayFlag){
$myD=(int)($timeDiff / $dis);
$timeDiff = ($timeDiff % $dis);
}
$myH=(int)($timeDiff / $his);
$timeDiff = ($timeDiff % $his);
$myM =(int)($timeDiff / $mis);
$myS =($timeDiff % $mis);
if($dayFlag){
$result = $myD.' Days '.$myH.':'.$myM.':'.$myS;
}else{
$result = $myH.':'.$myM.':'.$myS;
}
return $result;
}
$myDates=array();
$myDates[]= array("2007-03-15 10:00:00","2007-03-16 18:56:32");
$myDates[]= array("2007-03-15 10:00:00","2007-03-15 10:00:01");
$myDates[]= array("2003-07-08 10:00:00","2007-03-15 10:00:00");
$myDates[]= array("2007-03-15 10:00:00","2009-03-15 10:00:00");
$myDates[]= array("2007-03-15 10:00:00","2007-04-11 16:34:00");
foreach ($myDates as $duo){
echo "\n<br>".$duo[0].' --> '.$duo[1].' = '.timeDiffH($duo[0] , $duo[1] );
echo "\n<br>".$duo[0].' --> '.$duo[1].' = '.timeDiffH($duo[0] , $duo[1] ,true );
echo "\n<hr>";
}
?> | | |
|
| A Timing Class Categories : PHP, PHP Classes, Date Time | | | Finding the day of the week for a specific date.
Categories : PHP, Databases, MySQL, Date Time | | | A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time, Databases, PHP | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | PHP Round Clock - Must have Gif support to use this. Categories : PHP, Date Time, Graphics | | | A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed. Categories : Date Time, PHP, Complete Programs, Calendar | | | Open and Close your website in fixed times . Categories : PHP, PHP Classes, Cron, Date Time | | | mysql date/time converters Categories : PHP, MySQL, Databases, Date Time | | | Creates three SELECT form fields: Month, Day, and Year. You give it a string which will be used to make the name for the three fields, and a number of seconds to use as the default date. If you give it blank for this value, the current date is used. Categories : HTML and PHP, PHP, Date Time | | | If you want to create select buttons featuring current date this example will show you how... Categories : Date Time, HTML and PHP, PHP | | | Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example. Categories : PHP, Date Time, PHP Classes, Calendar | | | A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function. Categories : PHP, PHP Classes, Calendar, Date Time | | | calculus of the eastersunday Categories : BC math, PHP, Date Time, Databases | | | Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June). Categories : Calendar, Date Time, PHP | | | Monthly and Daily Upcoming Events calendar. Categories : Date Time, PostgreSQL, PHP, Calendar, Databases | |
|
|
|