The default single event template already includes a function to handle this. If you take a look at /wp-content/plugins/the-events-calendar/views/single.php on line 16 you will see the code for it. Make sure if you have done a template override on this file that you have the most recent code.