Add/update event dynamically from function.php

Hello,

How can we Add/update event dynamically using code?

I have a custom post type with custom date field. what i want is that according to this date field an event should be created automatically after saving/updating that post.

This should be achieve by using php code or shortcode in function.php.