Geçen Zamanı Gösteren Asp Fonksiyonu

ontedi

New member
<%
Function GecenZamaniBul(strVeri)
If strVeri = "" Then Exit Function
GecenSaniye = DateDiff("s", strVeri, now())
if GecenSaniye = 0 then
GecenZamaniBul = "Biraz önce"
elseif GecenSaniye >= 1 and GecenSaniye < 60 then
GecenZamaniBul = ""&GecenSaniye&" saniye önce"
elseif GecenSaniye >= 60 and GecenSaniye < 3600 then
GecenZamaniBul = ""&int(GecenSaniye/60)&" dakika önce"
elseif GecenSaniye >= 3600 and GecenSaniye < 86400 then
GecenZamaniBul = ""&int(GecenSaniye/3600)&" saat önce"
elseif GecenSaniye >= 86400 and GecenSaniye < 604800 then
GecenZamaniBul = ""&int(GecenSaniye/86400)&" gün önce"
elseif GecenSaniye >= 604800 and GecenSaniye < 2592000 then
GecenZamaniBul = ""&int(GecenSaniye/604800)&" hafta önce"
elseif GecenSaniye >= 2592000 and GecenSaniye < 31104000 then
GecenZamaniBul = ""&int(GecenSaniye/2592000)&" ay önce"
elseif GecenSaniye >= 31104000 then
GecenZamaniBul = ""&int(GecenSaniye/31104000)&" yıl önce"
end if
End Function
%>

Son zamanlarda meşhur olan tarih gösterim fonksiyonudur. "3 gün öce, 7 ay önce şeklinde vs.." gösterimleri mevcuttur. Geçmiş bir zaman: 24.02.2008
Gösterimi:
<%
strGecmisTarih = "24.02.2008"
response.write GecenZamaniBul(strGecmisTarih)
%>


Not: Alıntı değil, alınteri.
 

HTML

Üst