5 Replies Latest reply on Jan 10, 2011 9:10 AM by jfb00

    Convert Date stored in MYSQL to date flex can use

    djh88ukwb Level 1

      Hello All.

       

      I am trying to finish a simple log in script for a program i am working on.

       

      Its using amfphp to check a mysql database to ensure that the username and password that the user enters is in the database and flagged to allow them to log in,

       

      I have all this working fine.

       

      However the database also has a table named "Date" that contains a date in the format os DD/MM/YYYY  this date is generated by flex in a process earlier.   The field type for this date field is a varChar.

       

      My flex application also has a variable that contains the current Date. In the same format.

              <mx:DateFormatter id="DateDisplay"  formatString="DD/MM/YYYY"/>

                [Bindable] private var today:Date = new Date();

      and i have a label that displays it using the code below.

      DateDisplay.format(today)

       

      Now what i want to do is when the user clicks the log in button, in the result of the function that is run, i want to convert the date stored in the mysql table to a date variable so that i can compare it witht he actual date.   So that the user can not log in once the date has expired.

       

       

      The result function is as follows

      protected function qrycandidateLogin(event:ResultEvent):void
                  {
                      if(event.result.length > 0 && event.result[0].Taken =='Yes') {
                          Alert.show(LoginError,"Error");
                      }
                      else if (event.result.length > 0 )
                      {
                          viewstack1.selectedChild=welcome;  
                          userArray = event.result as ArrayCollection;
                      }
                      else
                          Alert.show("Please consult an account admin.", "Login failed");
                  }

       

      So i need to add the code to the first "Else IF" statement.  to ensure that the date hasnt expired.

       

      If anyone can help that would be great !

       

      Thanks


      Dave