I have 2 DateFields named startDate
and endDate
I want to set startDate
's Selected date to Current months start date and endDate
's Selected date to Current months End date.
How can I achieve this?
Thanks in advance...
2
votes
1 Answers
5
votes
You mean this?
package
{
import flash.display.Sprite;
public class DateExample extends Sprite
{
public function DateExample()
{
super();
var now:Date = new Date();
trace("now: " + now.toString());
var startDate:Date = new Date(now.fullYear, now.month, 1);
trace("start: " + startDate.toString());
var endDate:Date = new Date(now.fullYear, ++now.month, 0);
trace("end: " + endDate.toString());
}
}
}
output:
now: Fri Oct 21 00:15:09 GMT-0500 2011
start: Sat Oct 1 00:00:00 GMT-0500 2011
end: Mon Oct 31 00:00:00 GMT-0500 2011