-
Notifications
You must be signed in to change notification settings - Fork 0
/
tm.php
87 lines (68 loc) · 1.69 KB
/
tm.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
class tm{
function ymdToDate($Ymd){
return substr($Ymd, 6, 2)."/".substr($Ymd, 4, 2)."/".substr($Ymd, 0, 4);
}
function ymdToTime($Ymd){
global $convert;
return $convert->date2int(substr($Ymd, 6, 2)."/".substr($Ymd, 4, 2)."/".substr($Ymd, 0, 4));
}
function dateToDayStart($date=false){
global $convert;
if(!$date)
$date=date("d/m/Y", TIME);
return $convert->date2int($date, TIME);
}
function dateToDayEnd($date=false){
global $convert;
if(!$date)
$date=date("d/m/Y", TIME);
return $convert->date2int($date, TIME)+24*3600-1;
}
function timeToDayStart($time=false){
global $convert;
if(!$time)
$time=TIME;
$date=date("d/m/Y", $time);
return $convert->date2int($date, TIME);
}
function timeToDayEnd($date=false){
global $convert;
if(!$time)
$time=TIME;
$date=date("d/m/Y", $time);
return $convert->date2int($date, TIME)+24*3600-1;
}
function Ymd2Date($in){
return substr($in, 6, 2)."/".substr($in, 4, 2)."/".substr($in, 0, 4);
}
function Ymd2DayStart($in){
return strtotime($in);
}
function Ymd2DayEnd($in){
return strtotime($in)+24*3600-1;
}
function yearStart($year=false){
global $convert;
if(!$year)
$year=date("Y", TIME);
return $convert->date2int("01/01/".$year);
}
function yearEnd($year=false){
global $convert;
if(!$year)
$year=date("Y", TIME);
return $convert->date2int("01/01/".($year+1))-1;
}
function prevMonthDate($inDate){
global $convert;
$d=substr($inDate, 0, 2);
$monyhStartTime=$convert->date2int("01/".substr($inDate, 3))-1;
$preD=date("d", $monyhStartTime);
if($d>$preD)
$d=$preD;
return $d."/".date("m/Y", $monyhStartTime);
}
}
$tm = new tm;
?>