-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
50 lines (44 loc) · 1.16 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
// globally defined functions
function pprint($var, $name=NULL) {
// pretty print variables for debug
if (isset($name)) {
echo '<br>- ' . $name . '<br>';
}
$code = htmlentities(print_r($var, true));
echo <<<HTML
<style>
div {
background-color: #ddd;
padding: 8px;
margin: 10px 0px;
}
pre {
background-color: #ddd;
/* background: repeating-linear-gradient(
90deg,
#bbb,
#bbb 1px,
#ddd 1px,
#ddd 14px
); */
background: repeating-linear-gradient(
90deg,
#bbb,
#bbb 1px,
#ddd 1px,
#ddd 29px
);
padding: 0px; margin: 0px;
}
</style>
<div><pre>$code</pre></div>
HTML;
}
// calculate the difference between two dates in seconds
function dateDiffSeconds($date1 , $date2) {
$datetime1 = date_create($date1);
$datetime2 = date_create($date2);
$interval = date_diff($datetime1, $datetime2);
return $interval->format('%s');
}