These docs are for an old release. Info on upgrading to v6
edit doc

Event::setEnd

Sets an event’s end date.

event.setEnd( date )

date is something that must parse into a Date Object. It can also be null, in which case the event’s end will be cleared.

If you’d like to set both the start and end at the same time, use setDates instead.

If there are other events that share the same groupId, those events’ end dates will be similarly modified.