回答編集履歴
1
test
CHANGED
@@ -43,73 +43,3 @@
|
|
43
43
|
```
|
44
44
|
|
45
45
|
> 21 hours
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
多少野暮ったいかもしれないけど、こういうことだろうか?
|
50
|
-
|
51
|
-
```php
|
52
|
-
|
53
|
-
<?php
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
$last_login = new DateTime('2020-03-24 18:19');
|
58
|
-
|
59
|
-
$today = new DateTime('2020-03-25 15:19');
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if ($today->diff($last_login)->y < 1) {
|
64
|
-
|
65
|
-
if ($today->diff($last_login)->m < 1) {
|
66
|
-
|
67
|
-
if ($today->diff($last_login)->d < 1) {
|
68
|
-
|
69
|
-
if ($today->diff($last_login)->h < 1) {
|
70
|
-
|
71
|
-
if ($today->diff($last_login)->i < 1) {
|
72
|
-
|
73
|
-
echo $today->diff($last_login)->format('%s seconds');
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
else {
|
78
|
-
|
79
|
-
echo $today->diff($last_login)->format('%i minutes');
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
else {
|
86
|
-
|
87
|
-
echo $today->diff($last_login)->format('%h hours');
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
else {
|
94
|
-
|
95
|
-
echo $today->diff($last_login)->format('%d days');
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
else {
|
102
|
-
|
103
|
-
echo $today->diff($last_login)->format('%d months');
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
else {
|
110
|
-
|
111
|
-
echo $today->diff($last_login)->format('%y years');
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
```
|