-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathX-zaman-once-tarih-fonsiyonu.php
More file actions
35 lines (32 loc) · 839 Bytes
/
X-zaman-once-tarih-fonsiyonu.php
File metadata and controls
35 lines (32 loc) · 839 Bytes
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
<?php
// 5 saat önce, 3 dakika önce, 1 yıl önce
function timeConvert ( $zaman ){
$zaman = strtotime($zaman);
$zaman_farki = time() - $zaman;
$saniye = $zaman_farki;
$dakika = round($zaman_farki/60);
$saat = round($zaman_farki/3600);
$gun = round($zaman_farki/86400);
$hafta = round($zaman_farki/604800);
$ay = round($zaman_farki/2419200);
$yil = round($zaman_farki/29030400);
if( $saniye < 60 ){
if ($saniye == 0){
return "az önce";
} else {
return $saniye .' saniye önce';
}
} else if ( $dakika < 60 ){
return $dakika .' dakika önce';
} else if ( $saat < 24 ){
return $saat.' saat önce';
} else if ( $gun < 7 ){
return $gun .' gün önce';
} else if ( $hafta < 4 ){
return $hafta.' hafta önce';
} else if ( $ay < 12 ){
return $ay .' ay önce';
} else {
return $yil.' yıl önce';
}
}