1 | <?php
|
---|
2 | /*
|
---|
3 | * Position Yourself WP Plugin Functions
|
---|
4 | */
|
---|
5 |
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Trims all array elements
|
---|
9 | * @return array
|
---|
10 | */
|
---|
11 | if ( !function_exists('pyTrimArray') ) :
|
---|
12 | function pyTrimArray($totrim) {
|
---|
13 | if (is_array($totrim)) {
|
---|
14 | $totrim = array_map("trim", $totrim);
|
---|
15 | } else {
|
---|
16 | $totrim = trim($totrim);
|
---|
17 | }
|
---|
18 | return $totrim;
|
---|
19 | }
|
---|
20 | endif;
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * Output a clean version of array / object
|
---|
24 | */
|
---|
25 | if ( !function_exists('pyPre') ) :
|
---|
26 | function pyPre($array) {
|
---|
27 | echo "<pre>";
|
---|
28 | print_r($array);
|
---|
29 | echo "</pre>";
|
---|
30 | }
|
---|
31 | endif;
|
---|
32 |
|
---|
33 |
|
---|
34 | //Author Binu.v.Pillai
|
---|
35 | function diffTime($bigTime, $smallTime) {
|
---|
36 | //input format hh:mm:ss
|
---|
37 |
|
---|
38 | list($h1, $m1, $s1) = split(":", $bigTime);
|
---|
39 | list($h2, $m2, $s2) = split(":", $smallTime);
|
---|
40 |
|
---|
41 | $second1 = $s1 + ( $h1*3600 ) + ( $m1*60 );//converting it into seconds
|
---|
42 | $second2 = $s2 + ( $h2*3600 ) + ( $m2*60 );
|
---|
43 |
|
---|
44 | if ( $second1 == $second2 ) {
|
---|
45 | $resultTime = "00:00:00";
|
---|
46 | return $resultTime;
|
---|
47 | exit();
|
---|
48 | }
|
---|
49 | if ( $second1 < $second2 ) {
|
---|
50 | $second1 = $second1 + ( 24*60*60 );//adding 24 hours to it.
|
---|
51 | }
|
---|
52 | $second3 = $second1 - $second2;
|
---|
53 | //print $second3;
|
---|
54 | if ( $second3 == 0 ) {
|
---|
55 | $h3 = 0;
|
---|
56 | } else {
|
---|
57 | $h3 = floor( $second3/3600 );//find total hours
|
---|
58 | }
|
---|
59 |
|
---|
60 | $remSecond = $second3 - ( $h3*3600 );//get remaining seconds
|
---|
61 | if ( $remSecond == 0 ) {
|
---|
62 | $m3 = 0;
|
---|
63 | } else {
|
---|
64 | $m3 = floor( $remSecond / 60);// for finding remaining minutes
|
---|
65 | }
|
---|
66 |
|
---|
67 | $s3 = $remSecond - ( 60*$m3 );
|
---|
68 | if ( $h3 == 0 ) {
|
---|
69 | $h3 = "00";
|
---|
70 | }
|
---|
71 | if ( $m3 == 0 ) {
|
---|
72 | $m3="00";
|
---|
73 | }
|
---|
74 | if ( $s3 == 0 ) {
|
---|
75 | $s3="00";
|
---|
76 | }
|
---|
77 |
|
---|
78 | $resultTime = "$h3:$m3:$s3";
|
---|
79 |
|
---|
80 | return $resultTime;
|
---|
81 | }
|
---|
82 | ?> |
---|