Hello everyone,
I need a little help. I’m trying to make a script that requires me to show the
user how many years/months/weeks/hours/minutes the posted something (like
Posted: 2 days 1 hour 3 minutes ago). I have made an attempt but failed. When
the post becomes a month old it says something like "32 days" instead
of 1 month and also when the post becomes a year old it says "1 year 365
days". Maybe one of you can help me with my script.
<%
Function Time(post_time)
Dim strNow
Dim H
Dim M
Dim Y
Dim D
strNow = Now()
H = datediff("h",post_time,strNow)
M = datediff("n",post_time,strNow)
Y = datediff("yyyy",post_time,strNow)
D = int(h / 24) :if d > 0 then d = d & " days " :do while h
>= 24 :h = h - 24 :loop :else d = ""
Do While M >= 60
M = M - 60
Loop
Do While S >= 60
S = S - 60
Loop
If H > 0 Then
H = H & " hours "
Else
H = ""
End If
If M > 0 Then
M = M & "minutes "
Else
M = ""
End If
If Y > 0 Then
Y = Y & " years "
Else
Y = ""
End If
Response.Write y & d & h & m & s
End Function
%>
|