This is what I have:
startDate: DateTime.parse(dateEvent.split(' ').reversed.join()),
endDate: DateTime.parse(dateEvent.split(' ').reversed.join()),
dateEvent gives me the date selected in the format yyyyMMdd from the format dd MM yyyy.
I need to add the time to this in order to add it to the calendar. I receive this as timeHour and timeMinute which are individual numbers. example: 8:30am would come as 8 and 30, 8:30pm would come as 16 and 30.
The ideal result would be yyyyMMdd HH:mm:00
2
Answers
So the answer given was close, but the result was much simpler. I needed to add the line:
Then I could write my dates as a dateFormat which resulted in a simpler outcome as it could all be tied together in a String recognisable by the Calander apps:
This code will first parse the date string into a DateTime object. Then, it will create a TimeOfDay object with the specified hour and minute. Finally, it will add the time to the date and format the resulting DateTime object in the yyyyMMdd HH:mm:00 format.