CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Time comparison and cookies



May 15, 2000, 2:41 AM

Post #1 of 2 (1310 views)
Time comparison and cookies Can't Post


I want to compare 2 dates, one from a previous set cookie and the other one the current time...

Which format should I set the cooke at?
How do I compare dates in perl to see if one is older?
How do I split up the string from the cookie?


May 19, 2000, 7:08 AM

Post #2 of 2 (1310 views)
Re: Time comparison and cookies [In reply to] Can't Post

The easiest way would probably be to use the time since the epoch = the value returned by the time() function.

After that, you can use simple math to compare them :

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

if ($cookie{'lastvisit'} < time - 5*24*3600) {...}</pre><HR></BLOCKQUOTE>

Or use standard functions to extract dates etc. :

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

print "Your last visit was on ", scalar localtime($cookie{'lastvisit'}), "\n";</pre><HR></BLOCKQUOTE>


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives