skalie
07-02-2004, 08:54 AM
In the interests of prosperity.....
I've had a hell of a time trying to work out how to format the info from a DateField component to throw into a MySql database (without binding it to another component).
There was nothing on the net to be found, so I wrote this code ( in this case to be attached to an instance of a DateField ).
on (change) {
var displayedDate:Date = new Date();
var displayedDate:Date = this.selectedDate;
var day:Number = displayedDate.getDate();
var month:Number = displayedDate.getMonth();
var year:Number = displayedDate.getUTCFullYear();
if (day<10) {
var ad1:Number = 0;
} else {
var ad1:String = "";
}
if (month<10) {
var ad2:Number = 0;
} else {
var ad2:String = "";
}
trace("day :"+day);
trace("month :"+month);
trace("year :"+year);
trace(year+"-"+ad2+month+"-"+ad1+day);
}
Comments or improvements welcomed, hope this helps someone out one day
I've had a hell of a time trying to work out how to format the info from a DateField component to throw into a MySql database (without binding it to another component).
There was nothing on the net to be found, so I wrote this code ( in this case to be attached to an instance of a DateField ).
on (change) {
var displayedDate:Date = new Date();
var displayedDate:Date = this.selectedDate;
var day:Number = displayedDate.getDate();
var month:Number = displayedDate.getMonth();
var year:Number = displayedDate.getUTCFullYear();
if (day<10) {
var ad1:Number = 0;
} else {
var ad1:String = "";
}
if (month<10) {
var ad2:Number = 0;
} else {
var ad2:String = "";
}
trace("day :"+day);
trace("month :"+month);
trace("year :"+year);
trace(year+"-"+ad2+month+"-"+ad1+day);
}
Comments or improvements welcomed, hope this helps someone out one day