• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date comparison for validation.

Explorer ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

Hi people, good afternoon!

I would like to know how I can be creating a code that expires within a time, using getDate and time.

For example, having an input field, where I check if a token exists, and compare the dates to check if it is active within the period.

 

(example):

new InitialDate: DD/MM/YY
new EndDate: DD/MM/YY

function ... {

if(code.text = "itsCode")

{

if(InitialDate > EndDate)

{

gotoAndStop(2);

}

else

{

trace("error, expired");

}

TOPICS
ActionScript , Code , How to

Views

295

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

use the getTime() method of the date object

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 09, 2023 Jul 09, 2023

Copy link to clipboard

Copied

Hi Kosglad, can't find a way to get getData to add to the variable.

I put together this code and I'm still wondering how I can add, in date_now, the current date of the user.

Can you help me?

 

var date_start:Date = new Date(2023, 6, 10);
var date_now:Date = new Date(); // HERE!
var differenceInMilliseconds:Number = date_end.time - date_start.time;

const MILLISECOND_PER_SECOND:int = 1000;
const SECOND_PER_MINUTES:int = 60;
const MINUTES_PER_HOUR:int = 60;
const HOURS_PER_DAY:int = 24;

var differenceInSeconds:Number = differenceInMilliseconds / MILLISECOND_PER_SECOND;
var differenceInMinutes:Number = differenceInSeconds / SECOND_PER_MINUTES;
var differenceInHouse:Number = differenceInMinutes / MINUTES_PER_HOUR;
var differenceInDays:Number = differenceInHouse / HOURS_PER_DAY;

if (date_now > date_end)
{                    
trace("expired");
}
else
{
trace("approved");                    
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

don't you see an error?

 

the third line of your code contains date_end which is undefined.

 

p.s. there's no need to convert from ms to anything else when doing date comparisons unless you want to check for a certain number of seconds, or minutes, or hours etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

I understood!
I managed to make the code work with your help, however, I checked a possible loophole to fix.

If the user adjusts the configuration for a date earlier than the defined one, the code will indicate that it is approved.

In the Date 'now' variable, is there any way I can get this information online, without the need to be from the user's device?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

yes, you should retrieve it from your server or a public source.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

Would it be a website that is online, or something?

Exemple: https://www.horariodebrasilia.org

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

you would use your web host or a public site that supplies the timedate.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 10, 2023 Jul 10, 2023

Copy link to clipboard

Copied

No reference articles, I couldn't identify a function that I can add a parameter like site, or similar for verification.

Would you help me?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2023 Jul 11, 2023

Copy link to clipboard

Copied

what kind of app are you building with animate?  (eg, canvas, mobile app, something else?)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

I'm structuring a desktop application, @kglad 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2023 Jul 12, 2023

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines