Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Comparing Dates



******    message to minivend-users from Bill Randle <billr@exgate.tek.com>     ******

"Cameron B. Prince" wrote:
> Hi list,
> 
> I need to find out if a date in the database is before or after the current
> date.
[del]
> 
> Also, would code like this be better placed in a global sub, user tag or
> embedded in the page?
> 
> Here's the code I have so far:
[del]

Cameron,

In your script, instead of comparing each part of the date (year, month, etc.)
individually, convert your split date fields into a single 'time' value:

    [perl global=1]
	my @due_date = split /\//, $Scratch->{due_date};
	my $due_time = timelocal(0, 0, 0, $due_date[1], $due_date[0]-1,
$due_date[2]+100);
	return 1 if ($due_time < time() && $Scratch->{status});
	return undef;
    [/perl]

Also check the mailing list archives for a note I posted (a few weeks? a month?)
ago
on comparing dates.

	-Bill
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: