Title: Set expiry date programmatically
Last modified: August 12, 2020

---

# Set expiry date programmatically

 *  [kevinbrands](https://wordpress.org/support/users/kevinbrands/)
 * (@kevinbrands)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/set-expiry-date-programatically/)
 * Hello,
 * We are using a tool to import Events. When importing, we would also like to set
   an expiry date. Is it possible to do this programmatically?
 * Thanks in advance!
    -Kevin
    -  This topic was modified 5 years, 9 months ago by [kevinbrands](https://wordpress.org/support/users/kevinbrands/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [tazir](https://wordpress.org/support/users/tazir/)
 * (@tazir)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/set-expiry-date-programatically/#post-13339822)
 * yes, this is the basic code for its:
 *     ```
       	$opts = array('expireType'=>"private", 'id'=>$post_id);
       	$ts = get_gmt_from_date("$year-$month-$day $hour:$minute:0",'U');
       	_scheduleExpiratorEvent($post_id,$ts,$opts);
       ```
   
 *  [Dominic](https://wordpress.org/support/users/shifudominik/)
 * (@shifudominik)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/set-expiry-date-programatically/#post-13914542)
 * [@tazir](https://wordpress.org/support/users/tazir/) where should I paste the
   code from You to automatically set the expire date of posts?
 * Dominic

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Set expiry date programmatically’ is closed to new replies.

 * ![](https://ps.w.org/post-expirator/assets/icon-256x256.png?rev=3118683)
 * [Schedule Post Changes With PublishPress Future: Unpublish, Delete, Change Status, Trash, Change Categories](https://wordpress.org/plugins/post-expirator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-expirator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-expirator/)
 * [Active Topics](https://wordpress.org/support/plugin/post-expirator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-expirator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-expirator/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [Dominic](https://wordpress.org/support/users/shifudominik/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/set-expiry-date-programatically/#post-13914542)
 * Status: not resolved