PDA

View Full Version : Help for Date Functions


walkwithsabari
12-29-2008, 09:31 AM
:confused: Hi ! This is Sabari ..

I have an array of strings. The strings are in MM/DD/YYYY format.

From this how can I get the Month (0- jan, 1 - feb ... ) like that?

I have been tried with new Date(array[index]).month as Number.
It gives some other output.

But same situation for Day of the Month
new Date(array[index]).date as Number gives a correct Day.

Can anybody help me to resolve this?
Answers are welcome.

ljuwaidah
12-29-2008, 12:20 PM
This page should help, it has all the date functions: http://livedocs.adobe.com/flex/2/langref/Date.html

kahuja
01-01-2009, 08:52 PM
Try the following code:



<mx:Script>
<![CDATA[
import mx.controls.Alert;
private var dates = new Array();

[Bindable]
private var outputDates:String = "Dates:";

private function onInit():void
{
setupDates();
}


private function setupDates():void
{
dates[0] = "1/30/2008";
dates[1] = "2/28/2008";
dates[2] = "3/31/2008";
}

private function hitMe():void
{
outputDates = "New Dates:";

var tempDateString:String = "";
var length:int = dates.length;
for(var count:int = 0; count < length; count++)
{
var dateString:String = dates[count];
var newDate:Date = new Date(dateString);

outputDates = outputDates + "\nMonth: " + newDate.month
}
}
]]>
</mx:Script>

<mx:RichTextEditor id="output" text="{outputDates}"/>
<mx:Button id="hitme" click="hitMe();" label="Hit me to change dates"/>