-1
我試圖創建自動添加日期,但結果仍然是數學計算而不是日期計算。例如,如果您創建了+14,並且選擇了日期20-11-2016,結果應該是04-12-2016,但是我的函數結果仍然是數學計算和結果34-11-2016。感謝您的help.sorry英語不好flex builder 3:如何在datefield中自動創建dateadd日/月/年的過程
private function useDate(df_start:CalendarLayoutChangeEvent):void {
// Make sure selectedDate is not null.
if (df_start.currentTarget.selectedDate == null) {
return
}
//Access the Date object from the event object.
df_target.text=df_start.currentTarget.selectedDate.getFullYear() +'-'+
(df_start.currentTarget.selectedDate.getMonth()+ 1) +'-'+
(df_start.currentTarget.selectedDate.getDate() + 14);
}
這個函數在月份還有問題。你知道flex中的getMonth需要+1以及如何對月進行+1?我試圖用+1創建新的變種,但不工作。感謝您的幫助。 –
對於getMonth,你可以做date1.getMonth()+ 1.沒關係,因爲month從0開始在actionscript中開始。 df_target.text = date1.getFullYear()+' - '+ (df_start.currentTarget.selectedDate.getMonth()+ 1)+' - '+ date1.getDate(); – Sumit
非常感謝你@Sumit。它運作良好。 –