【php计算两个日期相隔多少年,多少月,多少天】教程文章相关的互联网学习教程文章

php计算指定文件夹信息(文件夹数,文件数,文件夹大小)

//格式化输出目录大小 单位:Bytes,KB,MB,GB//也可以用于统计目录数//site bbs.it-home.orgfunction getDirectorySize($path){ $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' && $file != '..' && !is_link ($nextpath)) { if (is_dir ($nextpath))...

php计算数组不为空元素个数

$arr = array( 1=>"11", 2=>"22", 3=>"33", 4=>"" ); print_r(count(array_filter($arr))); ?>

php计算日期相差天数(任意时间与当前时间的时间差)

function count_days($a,$b){ $a_dt=getdate($a); $b_dt=getdate($b); $a_new=mktime(12,0,0,$a_dt['mon'],$a_dt['mday'],$a_dt['year']); $b_new=mktime(12,0,0,$b_dt['mon'],$b_dt['mday'],$b_dt['year']); return round(abs($a_new-$b_new)/86400);}//今天与2008年10月11日相差多少天$date1=strtotime(time()); $date1=strtotime('10/11/2008');$result=count_days($date1,$date2);echo $result;?>方法2://今天与2008年9月9日相...

PHP计算当前程序执行时间

$pagestartime=microtime();?>网页内容......$pageendtime = microtime();$starttime = explode(" ",$pagestartime);$endtime = explode(" ",$pageendtime);$totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1];$timecost = sprintf("%s",$totaltime);echo "页面运行时间: $timecost 秒";?> 来源:PHP站中文网

php计算网页执行时间

microtime():获取毫秒级的UNIX时间戳 $t=microtime(); /* 你要执行的代码 */ echo "哦啦啦啦啦啦啦啦"; $t=microtime()-$t; echo "本次代码执行用了$t毫秒."; ?> 执行时间, php

php计算整个mysql数据库的大小

php计算连接的mysql数据库的大小,用MB,KB或者GB的格式返回 function CalcFullDatabaseSize($database, $db) { $tables = mysql_list_tables($database, $db); if (!$tables) { return -1; } $table_count = mysql_num_rows($tables); $size = 0; for ($i=0; $i < $table_count; $i++) { $tname = mysql_tablename($tables, $i); $r = mysql_query("SHOW TABLE STATUS FROM ".$database." LIK...

php计算页面执行时间代码

class c_Timer { var $t_start = 0; var $t_stop = 0; var $t_elapsed = 0; function start() { $this->t_start = microtime(); } function stop() { $this->t_stop = microtime(); } function elapsed() { if ($this->t_elapsed) { return $this->t_elapsed; } else { ...

php计算密码强度

下面的php代码用于测试给定密码的强度,最高强度为100 <?php/** * * @param String $string * @return float * * Returns a float between 0 and 100. The closer the number is to 100 the * the stronger password is; further from 100 the weaker the password is. */function password_strength($string){ $h = 0; $size = strlen($string); foreach(count_chars($string, 1) as $v){ $p = $v / $size;...

php计算指定目录下文件占用的空间

php计算指定目录下文件占用的空间 php中可以通过 RecursiveDirectoryIterator 扩展 DirectoryIterator的getChildren() 方法提供访问子目录中的每一个元素的方法,下面的代码通过遍历访问目录下的所有文件,获取他们暂用的空间。 $dir = new RecursiveDirectoryIterator('C:\wamp');$totalSize = 0;foreach (new RecursiveIteratorIterator($dir) as $file) { $totalSize += $file->getSize();}print "The total size is $totalS...

PHP计算地图上两点间的距离

<?phpclass GeoHelper{ /** * @param int $lat1 * @param int $lon1 * @param int $lat2 * @param int $lon2 * @param string $unit * @return */ public static function distance($lat1, $lon1, $lat2, $lon2, $unit = "K") { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad ($lat2)) * cos(d...

PHP计算日期差异

date_default_timezone_set("Asia/Calcutta");function dt_differ($start, $end){ $start = date("G:i:s:m:d:Y", strtotime($start)); $date1=explode(":", $start); $end = date("G:i:s:m:d:Y", strtotime($end)); $date2=explode(":", $end); $starttime = mktime(date($date1[0]),date($date1[1]),date($date1[2]), date($date1[3]),date($date1[4]),date($date1[5])); $endtime = mktime(date($date2[0]),date(...

PHP计算指定文件夹的信息(文件夹数,文件数,文件夹大小)

//代码也可以用于统计目录数//格式化输出目录大小 单位:Bytes,KB,MB,GB function getDirectorySize($path){ $totalsize = 0; $totalcount = 0; $dircount = 0; if ($handle = opendir ($path)) { while (false !== ($file = readdir($handle))) { $nextpath = $path . '/' . $file; if ($file != '.' && $file != '..' && !is_link ($nextpath)) { if (is_dir ($nextpath)) { ...

php计算两个坐标(经度,纬度)之间的距离

php计算两个坐标(经度,纬度)之间的距离,返回结果为米或者千米 function distance($lat1, $lng1, $lat2, $lng2, $miles = true){ $pi80 = M_PI / 180; $lat1 *= $pi80; $lng1 *= $pi80; $lat2 *= $pi80; $lng2 *= $pi80; $r = 6372.797; // mean radius of Earth in km $dlat = $lat2 - $lat1; $dlng = $lng2 - $lng1; $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($d...

PHP计算两点经纬度之间的距离代码

以下是对PHP计算2点经纬度之间的距离代码进行了分析介绍 function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { $theta = $longitude1 - $longitude2; $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); $miles = acos($miles); $miles = rad...

PHP计算两个经纬度之间的距离

function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { $theta = $longitude1 - $longitude2; $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); $miles = acos($miles); $miles = rad2deg($miles); $miles = $miles * 60 * 1.1515; $feet = $miles * 5280; $yards =...