Here in WordPress.org you have a example to do that:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post
Look also here to see when it modified
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Regards.
Here in WordPress.org you have a example to do that:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_insert_post
Look also here to see when it modified
https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Regards.