It's been a long time since I've posted anything! Possibly because I haven't been doing much development recently :(
Anyway I needed to be able to subtract a day from today's date in Flex, so that I could default one DatePicker field to today and a second DatePicker to yesterday's date.
Turns out it's pretty easy.
Today's date:
<
pre
class
=
"brush: html"
>
<mx:DateField id="endDate" width="150" formatString="MM/DD/YYYY" showToday="true" styleName="Date" yearNavigationEnabled="true" editable="true" selectedDate="{new Date()}"/>
</
pre
>
Yesterday:
<
pre
class
=
"brush: html"
>
<mx:DateField id="startDate" width="150" formatString="MM/DD/YYYY" showToday="true" styleName="Date" yearNavigationEnabled="true" editable="true" selectedDate="{DateUtils.addDays(new Date(),-1)}"/>
</
pre
>
In my project, DateUtils refers to org.as3commons.lang.DateUtils
Wednesday, 30 January 2013
Flex: Add or subtract days from date
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment