tags:

views:

167

answers:

1

Is there anything wrong with following snippet of code?

var d:Date = DateField.dateToString(myDateField.text,"DD/MM/YYYY");
      testTextArea.text = d.getSeconds().toString();

Error: Implicit coercion of a value of type String to an unrelated type Date.

+1  A: 

Here is your problem: DateField.dateToString's first parameter is supposed to be a date. It then takes that date and returns a string using the second parameter as a format string.

It looks like you're trying to convert the string to a date (the other way around) so you can get the seconds from it and put it in the text area. The DateField control has a selectedDate parameter that will give you the date you need. Then you just run this code to put it in the text area:

testTextArea.text = myDateField.selectedDate.getSeconds().toString();
Gabriel McAdams
It should work but in testTextArea I am getting a zero only. Don't know why.
baltusaj
What do you get if you do this:testTextArea.text = DateField.dateToString(myDateField.selectedDate,"DD/MM/YYYY");
Gabriel McAdams