I need to allow users to enter time into an appointment
application I'm creating. I need the value of the input to be
stored as a Date-type in my db table. So far I've created an hour
and minutes text input, and a combo box AM/PM selection. Since Flex
doesn't have any time-based input components similar to dateField,
this is the only way I've been able to correctly capture time.
I have variable = hour.text + ':' +minute.text + ' '
+ampm.text to put the time in a string format. This works, but now
I don't know how to convert it from string to date.
Nevermind. Figured it out. For those that want to know...
declare your time variables...
In the function to insert the time into your db table,
set/convert each to the text input strings...
hour = Number(hourInput.text)
minute = Number(minInput.text)
second = Number(secInput.text)
ampm = ampmInput.text // no conversion needed
In your insert function, declare a variable to hold your time
var mytime:Date = new Date();
use the attributes of the object to set the hour, minutes,
seconds, am/pm. The am/pm is tricky -- there is no attribute for
this, so you have to set the hour as if it were military time (24
hour), like so...