-
Can I format the Date in the DateField Component
I searched for posts on this component, but didn't really find anything on formatting it. I'm using FlashMX2004pro, and when I just drag the component onto the stage, it's default format is in "18 Jul 2005".
All I want to do is reformt this date so that it stores and displays MM/DD/YYYY format.
Can this be done? Any help is greatly appreciated, thanks!
-
Senior Member
http://flashmx2004.com/forums/index.php?showtopic=4805
I use this dateformat.as function by Darron Shall. Unfortunatly it isn't available on the site currently, surely just a minor glitch.
it is your mind that decides - it is with your mind that you fly
vevmedia
-
Yes, this can be done. Flash explains how to do this in the help files. I did a search for datefield. Then look under using components.
TJdub
-
I found a function in the Help files, called Datefield.dateformatter, and it has a sample of what I want the date to look like:
on (change) {
dtfReceivedDate.dateFormatter = function(date){
return d.getFullYear()+"/ "+(d.getMonth()+1)+"/ "+d.getDate();
};
}
So I put this in the on change event of the component, but it doesn't work. Not sure where to put this? Any help is appreciated, thanks!!
-
Mine is done use like this
if u put that script in the component, u can change enough dtfReceivedDate whit this
so ... like this:
on (change) {
this.dateFormatter = function(date){
return d.getFullYear()+"/ "+(d.getMonth()+1)+"/ "+d.getDate();
};
}
-
Yes, you can format the Date of DateField Component
Just copy and paste below code on your DateField Component.....
on (change) {
trace("Date on change !");
this.dateFormatter = function(date){
//return date.getFullYear()+"/ "+(date.getMonth()+1)+"/ "+date.getDate();
return getMonthAsString(date.getMonth()+1)+" "+date.getDate()+", "+date.getFullYear();
};
function getMonthAsString(month:Number):String {
var monthNames_array:Array = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
return monthNames_array[month];
}
}
It will show the Date in new format
-
Above code will show current Month +1 in Date Use below code........ to get current month in new format
Last edited by garg; 03-20-2008 at 03:05 AM.
-
Originally Posted by garg
Just copy and paste below code on your DateField Component.....
on(load) {
this.dateFormatter = function(date){
//return date.getFullYear()+"/ "+(date.getMonth()+1)+"/ "+date.getDate();
return getMonthAsString(date.getMonth())+" "+date.getDate()+", "+date.getFullYear();
};
function getMonthAsString(month:Number):String {
var monthNames_array:Array = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
return monthNames_array[month];
}
this.selectedDate = new Date();
}
It will show the Date in new format
Last edited by garg; 03-20-2008 at 03:19 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|