|
|
 |
|
October 25th, 2007, 05:48 AM
|
#21
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Thanks: 0
Thanked 4 Times in 3 Posts
|
Re: Your last visit is Today??
Ohh I see.. I get the idea now. Let me go back and play with my code.
I'll let you know yesterday! I mean tomorow.. lol
Thanks..
|
|
|
October 25th, 2007, 05:55 AM
|
#22
|
|
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 22
Posts: 592
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Your last visit is Today??
|
|
|
October 25th, 2007, 05:58 AM
|
#23
|
SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
|
Re: Your last visit is Today??
Go away... Smartie pants... lol  
|
|
|
October 25th, 2007, 06:36 AM
|
#24
|
|
Elite Veteran
SuperMember
Join Date: Jul 2003
Location: Southern UK
Age: 35
Posts: 3,126
Thanks: 28
Thanked 22 Times in 19 Posts
|
Re: Your last visit is Today??
Instead of this code
Code:
dim dd, mm, yyyy, newtime, newdate
dd=day(date)
if len(dd)=1 then
dd="0" & dd
end if
mm=month(date)
if len(mm)=1 then
mm="0" & mm
end if
yyyy=year(date)
'getting new date
newdate = dd & "-" & mm & "-" & yyyy
Use this:-
Code:
newdate = date(now)
DO NOT store 'today' in the database.... store an actual date/time instead
The correct method to show 'today' would be a comparison when displaying the thing....
not when entering it in the database.
Does that make sense?
Last edited by Monie; October 25th, 2007 at 08:53 PM..
Reason: correcting the [CODE] tag, hehehe...
|
|
|
October 25th, 2007, 06:55 AM
|
#25
|
|
Elite Veteran
Join Date: Sep 2006
Location: Bridgnorth
Age: 23
Posts: 2,048
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Your last visit is Today??
My head hurts 
|
|
|
October 25th, 2007, 07:07 AM
|
#26
|
SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
|
Re: Your last visit is Today??
Quote:
Originally Posted by Daniel
My head hurts 
|
Thats ASP for ya 
|
|
|
October 25th, 2007, 09:06 PM
|
#27
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Thanks: 0
Thanked 4 Times in 3 Posts
|
Re: Your last visit is Today??
Hey guys.. check out what I've come up with!
I don't know if this way can be consider a "creative" way, but I have accomplished what I am trying to get.
It's not a PHP code, I just use the php tag so that I get a nice colorful ASP code, lol.
Code:
<%
dim dd, mm, yyyy, newtime, newdatetoday, newdateyesterday, newdatelastweek, lastweek, yesterday
dd = day(date) //todays date
yesterday = dd - 1 //yesterdays date
lastweek = dd - 7 //last week date
mm = month(date)
yyyy=year(date)
If Len(dd) = 1 Then
dd="0" & dd //Add '0' to DD that start with 1-9
End If
If len(mm) = 1 Then
mm="0" & mm
End If
//Todays date
newdatetoday = dd & "-" & mm & "-" & yyyy
//Yesterdays date
newdateyesterday = yesterday & "-" & mm & "-" & yyyy
//Last Week date (exactly 7 days ago)
newdatelastweek = lastweek & "-" & mm & "-" & yyyy
//Get time
newtime = time()
dim lastvisit
lastvisit = rs("lastactivedate")
If (cdate(lastvisit)) = (cdate(newdatelastweek)) Then
lastvisit = "Last Week"
Else If (cdate(lastvisit)) = (cdate(newdateyesterday)) Then
lastvisit = "Yesterday"
Else If (cdate(lastvisit)) = (cdate(newdatetoday)) Then
lastvisit = "Today"
Else
lastvisit = rs("lastactivedate")
End If
%>
Your last activity: <%Response.Write(lastvisit)%>
CDate function converts a valid date (and time) expression to type Date. After converting them, I found out I can make the comparison directly. I don't know if this can be done in PHP?
Hey Rob, I'll check out your code!
Last edited by Monie; November 2nd, 2007 at 01:56 AM..
|
|
|
November 1st, 2007, 01:16 AM
|
#28
|
|
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 28
Posts: 1,628
Thanks: 0
Thanked 4 Times in 3 Posts
|
Re: Your last visit is Today??
I got it the updated version, much more structured and understandable:
Code:
<%
Dim todaytime, todaydate, yesterdaysdate, lastweekdate
todaydate = (cdate(date())) 'today date
yesterdaysdate = (cdate(date())) - 1 'yesterdays date
lastweekdate = (cdate(date())) - 7 'lastweek date
todaytime = FormatDateTime(Now(), vbShortTime) 'show today time in mm:hh format (24 hour clock)
If Session("name") <> "" Then
dim lastvisit
lastvisit = rs("lastactivedate")
If lastvisit <> "" Then
If (cdate(lastvisit)) = lastweekdate Then
lastvisit = "Last Week"
ElseIf (cdate(lastvisit)) = yesterdaysdate Then
lastvisit = "Yesterday"
ElseIf (cdate(lastvisit)) = todaydate Then
lastvisit = "Today"
Else
lastvisit = rs("lastactivedate")
End If
End If
End If
%>
Code:
<body>
You last visited: <%Response.Write(lastvisit)%>
</body>
Last edited by Monie; November 2nd, 2007 at 01:55 AM..
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|