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
|
<? class DateClass { var $strDate; var $intDate; var $nYear; var $nMonth; var $nDay; var $LastDay; var $ChangedDate;
function DateClass() { return true; } function Init($date) { if(is_int($date)){
$this->intDate = $date; $this->strDate = strftime("%Y-%m-%d",$date); } else $this->strDate = $date;
$aDate = explode("-",$this->strDate); $this->nYear = $aDate[0]; $this->nMonth = $aDate[1]; $this->nDay = $aDate[2]; $this->LastDay = strftime("%d",mktime(0,0,0,$this->nMonth+1,0,$this->nYear)); } function addYear($date,$val) { if($date) $this->Init($date); $AddedDate = mktime(0,0,0,(int)$this->nMonth+1,0,$this->nYear+$val); $AddedLastDay = strftime("%d",$AddedDate); if($this->nDay >= $AddedLastDay) $this->ChangedDate = strftime("%Y-%m",$AddedDate)."-".$AddedLastDay; else $this->ChangedDate = strftime("%Y-%m-%d",mktime(0,0,0,$this->nMonth,$this->nDay,$this->nYear+$val)); return $this->ChangedDate; } function addMonth($date,$val) { if($date) $this->Init($date); $AddedDate = mktime(0,0,0,($this->nMonth+$val)+1,0,$this->nYear); $AddedLastDay = strftime("%d",$AddedDate); if($this->nDay >= $AddedLastDay) $this->ChangedDate = strftime("%Y-%m",$AddedDate)."-".$AddedLastDay; else $this->ChangedDate = strftime("%Y-%m-%d",mktime(0,0,0,$this->nMonth+$val,$this->nDay,$this->nYear)); return $this->ChangedDate; } function addDay($date,$val) { if($date) $this->Init($date); $AddedDay = mktime(0,0,0,$this->nMonth,$this->nDay+$val,$this->nYear); $this->ChangedDate = strftime("%Y-%m-%d",$AddedDay); return $this->ChangedDate; } function subYear($date,$val) { if($date) $this->Init($date); $SubedDate = mktime(0,0,0,(int)$this->nMonth+1,0,$this->nYear-$val); $SubedLastDay = strftime("%d",$SubedDate); if($this->nDay >= $SubedLastDay) $this->ChangedDate = strftime("%Y-%m",$SubedDate)."-".$SubedLastDay; else $this->ChangedDate = strftime("%Y-%m-%d",mktime(0,0,0,$this->nMonth,$this->nDay,$this->nYear-$val)); return $this->ChangedDate; } function subMonth($date,$val) { if($date) $this->Init($date); $SubedDate = mktime(0,0,0,($this->nMonth-$val)+1,0,$this->nYear); $SubedLastDay = strftime("%d",$SubedDate); if($this->nDay >= $SubedLastDay) $this->ChangedDate = strftime("%Y-%m",$SubedDate)."-".$SubedLastDay; else $this->ChangedDate = strftime("%Y-%m-%d",mktime(0,0,0,$this->nMonth-$val,$this->nDay,$this->nYear)); return $this->ChangedDate; } function subDay($date,$val) { if($date) $this->Init($date); $SubedDay = mktime(0,0,0,$this->nMonth,$this->nDay-$val,$this->nYear); $this->ChangedDate = strftime("%Y-%m-%d",$SubedDay); return $this->ChangedDate; } }
?>
|