Hi Wyatt,<br><br>I'm sure there're more elegant ways of doing this (and I'm probably about to hear about 8 of them <grin> but I have a real lazy way of doing this in Perl.<br><br>Save dates as datetime strings in the format 'YYYYMMDDHHMISS' with the HH in 24hr clock.<br><br>You can then sort data by them, comparisons work as you would expect and you can get just the date portion like this:<br><br>$date = substr($datetimevar,0,6);<br><br>and the time portion like this:<br><br>$time = substr($datetimevar,7,6);<br><br>So - get the current time with localtime(time) and build a string with the same format as your saved dates. <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href=
<being more specific><br><br>i can sort the dates just fine. what i need is to compare them for the purpose of evaluating there difference. for example, is my saved date 30 days old? 90 days old? and so on. i can do this in javascript and vbscript with a simple function call.
I have found taken to leaving the date in seconds since january 1, 1970 as supplied by 'time'.<br><br>That way data comparisons, subtraction, etc is extremely simple. If wanted to see if the saved date was older that 30 days, <br><br>1 - read $saved date from file <br>2 - get current date with '$date = time;'<br>3 - how many seconds in 30 days - $month = ( 60sec x 60min x 24hr x 30days)<br>4 - if ($date - $month > $saved) { do something; } <br><br>maybe this helps?? <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
There're some modules on CPAN that do date manipulation as well. <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href=
use Date::Manip;<br><br>@time = localtime(time) gives you the broken down info<br>$time = &UnixDate(@time) gives you the epoch seconds<br><br>If you store &UnixDate(@your_time), you can compare it to the time variable which gives you current epoch seconds <p> Sincerely,<br><a href=mailto: > </a><br><a href=
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.