Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8832377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:30:55+00:00 2026-06-14T08:30:55+00:00

I could find things for MX components, but I can’t it to work on

  • 0

I could find things for MX components, but I can’t it to work on spark components.

I just want to display the current day and date in a label.

I have tried this (see code), but I only get back function Function(){}

<?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            currentState="login" tabBarVisible="{currentState!='login'}">

        <s:states>
            <s:State name="login"/>
            <s:State name="planner"/>
        </s:states>

<fx:Script>
    <![CDATA[

        import mx.rpc.events.ResultEvent;
//private function login() :void
//{
//loginservice.send();
//}

        private function checkLogin(evt:ResultEvent):void

        {

            if(loginservice.lastResult.loginsuccess == "yes")

            {

                currentState = "planner";

            } 
            if(evt.result.loginsuccess == "no")

            {
                statusLabel.text = "Incorrect. (Try user/password)";

            }       

        }

        protected function submit_clickHandler(event:MouseEvent):void
        {
            // TODO Auto-generated method stub

        }



        public function displayDate():void {
            var now:Date = new Date();
            var day_int:int = now.getDate(); //gets day of the month
            var month_int:int = (now.getMonth()+1); // gets month. Months are given from 0 to 11, so you need to do +1 here
            var year_int:int = now.getFullYear(); // gets year

            var day_string:String;
            //display always 2 digits for a month, so '02' instead of just '2' for February
            if (day_int < 10) {
                day_string = "0" + day_int.toString();
            }
            else {
                day_string = day_int.toString();
            }

            var month_string:String;
            //display always 2 digits for a day, so '02' instead of just '2'
            if (month_int < 10) { 
                month_string = "0" + month_int.toString();
            }
            else {
                month_string = month_int.toString();
            }

            var year_string:String = year_int.toString();

            // note: this is displaying the date in the DD/MM/YYYY format, this same format is also set for the Datefield below!
            //DateSelect.text = day_string + "/" + month_string + "/" + year_string;
        }

    ]]>
</fx:Script>


    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->

        <s:HTTPService id="loginservice"
                       method="GET"
                       url="http://localhost:8888/MenuPlannerApp/services/login4.php"
                       useProxy="false"
                       result="checkLogin(event)">
            <s:request xmlns="">

                <email>{email.text}</email>

                <password>{password.text}</password>
            </s:request>
        </s:HTTPService>

    </fx:Declarations>
    <s:BorderContainer includeIn="login" width="100%" height="100%" >
        <s:Label id="statusLabel" />  
        <s:TextInput id="email" y="192" left="15" right="15" text="email"/>
        <s:TextInput id="password" y="247" left="15" right="15" text="password" displayAsPassword="true"/>
        <s:Button id="submit" y="306" right="15" width="100" height="30"
                  label="Login" click="loginservice.send()"/>
        <s:Button id="LoginCreate" y="306" left="15" width="100" height="30"
                  label="Create"/>
        <s:Label x="166" y="39" width="113" height="101" fontSize="30"
                 text="Menu&#xd;Planner"/>
    </s:BorderContainer>
    <s:BorderContainer includeIn="planner" width="100%" height="100%">
    <s:Label text="{displayDate}" />


<s:HGroup y="10" width="320" height="46" horizontalAlign="center"
          textAlign="center">

</s:HGroup>
    <s:VGroup includeIn="planner" >
     </s:VGroup>

    </s:BorderContainer>
</s:View>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:30:56+00:00Added an answer on June 14, 2026 at 8:30 am

    change this:

    // offset is today +/- a set number of days
    // displayDate(-1) returns string for yesterday
    // displayDate(1) returns string for tomorrow etc
    public function displayDate(offset:int=0):String {
        var formattedString:String;
    
        var now:Date = new Date();
        var day_int:int = now.getDate() + offset; //gets day of the month
        var month_int:int = (now.getMonth()+1); // gets month. Months are given from 0 to 11, so you need to do +1 here
        var year_int:int = now.getFullYear(); // gets year
    
        var day_string:String;
        //display always 2 digits for a month, so '02' instead of just '2' for February
        if (day_int < 10) {
            day_string = "0" + day_int.toString();
        }
        else {
            day_string = day_int.toString();
        }
    
        var month_string:String;
        //display always 2 digits for a day, so '02' instead of just '2'
        if (month_int < 10) { 
            month_string = "0" + month_int.toString();
        }
        else {
            month_string = month_int.toString();
        }
    
        var year_string:String = year_int.toString();
    
        formattedString = day_string + "/" + month_string + "/" + year_string;
    
        return formattedString;
    }
    

    the in mxml you would use it like this:

    <s:Label text="{ displayDate(-3) }" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All the answers I could find recommended adding display:none to css... but for a
This could save me so much time. Sometimes I find myself writing things like
I've tried various things and googled multiple hours but couldn't find a solution to
I could find the answer if I read a complete chapter/book about multithreading, but
This has to be a dumb question, but I can't seem to find the
I'm trying to find the best components I could use to build something similar
Given a reference date I need to find the following say 'Wednesday'. Just to
The only instructions I could find are here: http://eigenclass.org/hiki/fast-widefinder and on the old jocaml
All the examples I could find of flexible box model show stuff expanding either
Does anyone know where I could find this file on Ubuntu?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.