PHP: Load Time Script

PHP: Load Time

Load Time


This one is a must for developers and system admins. You need to know how long your site takes to load. Nobody sticks around waiting for a site to load anymore – there’s way too much content out there for that. Use this script to find out if your site is taking too long, and if it is, fix it. (more…)

PHP: Getting the difference between two time strings

To get the difference between two time strings use this code

<?php

function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("2002-04-16 10:00:00","2002-03-16 18:56:32");

?>

PHP: How to Get the Current Page URL

If you want to get the current page URL, you can use the following code:

<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER&#91;"HTTPS"&#93; == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER&#91;"SERVER_PORT"&#93; != "80") {
  $pageURL .= $_SERVER&#91;"SERVER_NAME"&#93;.":".$_SERVER&#91;"SERVER_PORT"&#93;.$_SERVER&#91;"REQUEST_URI"&#93;;
 } else {
  $pageURL .= $_SERVER&#91;"SERVER_NAME"&#93;.$_SERVER&#91;"REQUEST_URI"&#93;;
 }
 return $pageURL;
}
?>
<?php
  echo curPageURL();
?>
Page 3 of 3123

Pin It on Pinterest