|
-
expiration date
Hi all,
I'm wating for a client to pay up and would like to get the money soon. They have told me the payment is in the mail but it's been over a week and I have not received anything. Anyway, I would like to set up a movie that will "expire" if the payment is not received by a certain date (considering he may lock me out of the site and I'll have no way of removing the files already uploaded). I've tried this piece of code, but it doesn't want to work:
expiryDATE = "2/8/2003";
myDate = new Date();
dateTODAY = (myDate.getMonth()+"/"+myDate.getDate()+"/"+myDate.getFullYear());
dateEXPIRE = "expiryDATE";
if (dateTODAY >= dateEXPIRE) {
gotoAndStop("Payment", 1);
} else {
gotoAndPlay("Scene 3", 1);
}
Any suggestion as to what I'm doing wrong? (I mean besides uploading the files before I was paid! It's a long story and they were an affiliate of my former employer.)
Thanks,
Liquid4012
"Life is the crummiest book I ever read, there isn't a hook...Just a lot of cheap shots, pictures to shock, and characters an amateur would never dream up."
-
You need to get rid of the "/"'s and treat the dates as numbers.
code:
// expiration date
expiration = "282004";
// new date object
todaysDate = new Date();
// day of month
currentDate = todaysDate.getDate();
// month of year (add 1 because this returns 0-11)
currentMonth = todaysDate.getMonth() + 1;
// year (4 digits)
currentYear = todaysDate.getFullYear();
// put them together
current = currentMonth add currentDate add currentYear;
// Compare dates
if (Number(current) >= Number(expiration)) {
// Request payment
}else{
// Work as normal
}
When you do this be sure to make your client aware of it, unless you don't want any future work from him.
www.electricbluemonkey.com
-
You'll need to do something slightly different, actually. Writing Feb 8, 2004 as 282004 is not the best approach. In this format, January 1 of 2005 is "less than" the expiration date.
Either write the date as YYYYMMDD, always padding out to two-digit month and day, or use milliseconds since 1/1/1970, returned by Date.UTC().
The problem with your original code was that you were trying to compare two strings, not two numbers.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|