[SalesForce] apex:actionFunction with apex:param Param not setting

I'm trying to set a controller property, using apex:param in an actionFunction but the properties aren't being set.
This is my actionFunction:

<apex:actionFunction action="{!setStartEndDates}" name="setStartEndDates" rerender="empty_panel">
    <apex:param name="startDate" assignTo="{!StartDateTime}" value=""/>
    <apex:param name="endDate" assignTo="{!EndDateTime}" value=""/>
</apex:actionFunction>

Javascript – start and end are both js moments:

select: function(start, end, jsEvent, view) {
    setStartEndDates(start._d, end._d);
},

And controller:

public String StartDateTime {get; set;}

public String EndDateTime {get; set;}

public PageReference setStartEndDates() {
    CommonLog.debug('start: ' + StartDateTime);
    CommonLog.debug('end: ' + EndDateTime);
    return null;
}

When I log out the date properties, they're both null. I have another actionFunction set up in exactly the same way which is working fine and I can't figure out why this one isn't working. I've tried making the properties DateTime, and passing the full moment object as the param.

Best Answer

Found out what the problem was and thought I'd post it here in case anyone else has the same issue. Because the start and end were objects (moment), they weren't casting properly to the controller properties. My solution was:

Javascript:

select: function(start, end, jsEvent, view) {
    setStartEndDatesAF(start.format('YYYY-MM-DD HH:mm:ss'), end.format('YYYY-MM-DD HH:mm:ss'));
},

Controller:

public String StartDateTime {get; set;}
public DateTime startDt {get; set;}

public String EndDateTime {get; set;}
public DateTime endDt {get; set;}

public PageReference setStartEndDates() {
    startDt = DateTime.valueOf(StartDateTime);
    endDt = DateTime.valueOf(EndDateTime);
    //FullCalendar selected end is exclusive - deduct 1 second to get inclusive end
    endDt = endDt.addSeconds(-1);
    return null;
}