- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
<?php
/*
> 60 seconds - "s"
> 60 minutes - "m"
> 24 hours - "h"
> 30 days - "d"
< 30 days - "5 sep 2010"
*/
class Date {
public static function DateAgo($DateTime) {
$s = s; $m = m; $h = h; $d = d;
$Now = date('Y-m-d H:i:s');
$Now = time();
$Year = substr($DateTime, 0, 4);
$Month = substr($DateTime, 5, 2);
$Day = substr($DateTime, 8, 2);
$Hour = substr($DateTime, 11, 2);
$Minute = substr($DateTime, 14, 2);
$Second = substr($DateTime, 17, 2);
$Time = mktime($Hour, $Minute, $Second, $Month, $Day, $Year);
$Difference = $Now - $Time;
if($Difference < 60) {
$Ago = $Difference.$s;
} elseif($Difference < (60 * 60)) {
$Ago = floor($Difference / 60).$m;
} elseif($Difference < (60 * 60 * 24)) {
$Ago = floor($Difference / (60 * 60)).$h;
} elseif($Difference < (60 * 60 * 24 * 30)) {
$Ago = floor($Difference / (60 * 60 * 24)).$d;
} else {
$Ago = $Day.'.'.$Month.'.'.$Year;
}
return $Ago;
}
} // End class
?>
Забирайте целиком! Нашёл в CMS от http://fn85.ru/ охрененный класс для работы с датами!
gost 18.05.2016 15:12 # +1
chtulhu 18.05.2016 17:56 # +1
bormand 18.05.2016 18:49 # +1