# Can you help me format a date?

**URL:** <https://forum.kirupa.com/t/can-you-help-me-format-a-date/155987>\
**Category:** flash\
**Created:** [July 21, 2005, 6:55pm UTC](https://forum.kirupa.com/t/can-you-help-me-format-a-date/155987 "2005-07-21T18:55:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mh22gw](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@mh22gw](https://forum.kirupa.com/u/mh22gw)\
**Post date:** [July 21, 2005, 6:55pm UTC](https://forum.kirupa.com/t/can-you-help-me-format-a-date/155987/1 "2005-07-21T18:55:19Z")

</div>

I try to format a date that I Take from a datechooser. My code looks lake this.

```auto
 
calListener = new Object()
calListener.change = function(eventObj:Object) { 
var mySelectedDate:String = eventObj.target.selectedDate; 
myDate.dateFormatter = function(d:Date) {
mySelectedDate = d.getFullYear() +"-"+ (d.getMonth()+1) +"-"+ d.getDate();
return mySelectedDate
}
trace (mySelectedDate);
}
calMyCalendar.addEventListener("change", calListener);

```

I want to have the date in this format 2005-07-21.
