Title: calculated date
Last modified: August 30, 2016

---

# calculated date

 *  Resolved [fmalinge](https://wordpress.org/support/users/fmalinge/)
 * (@fmalinge)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/calculated-date/)
 * hi,
    I would like to calculate a date + x days, is this plug in can to that i
   have an acf field date_from and i would like to display a date_to, but this code
   doesnt work (php statement) //date From $dateFrom= get_field(‘date_from’);
 *  // month to add
    $month = 2;
 *  // transform
    $dateFromTimestamp = strtotime($dateFrom);
 *  // calcul (seems to be wrong)
    $dateTo = date(‘d-m-Y’, strtotime(‘+’.$duree.’
   month’, $dateFromTimestamp )); // set the field update_field( $date_to, $dateTo);
 * PS I M NOT A PHP PRO 🙂
 * Many thanks
 * [https://wordpress.org/plugins/validated-field-for-acf/](https://wordpress.org/plugins/validated-field-for-acf/)

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

 *  Plugin Author [doublesharp](https://wordpress.org/support/users/doublesharp/)
 * (@doublesharp)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/calculated-date/#post-6664693)
 * HI [@fmalinge](https://wordpress.org/support/users/fmalinge/) – this plugin is
   designed to validate inputs of a particular field, but it can’t set the values
   of other fields. I do have an add-on planned that would be able to accomplish
   this, but it won’t be ready in the near term.
 * Looking at your sample code, you probably want to hook to the meta update actions
   for the `date_from` field, then update your other meta field value. See this 
   StackOverflow post for more info: [http://wordpress.stackexchange.com/questions/16835/how-to-hook-update-post-meta-and-delete-post-meta](http://wordpress.stackexchange.com/questions/16835/how-to-hook-update-post-meta-and-delete-post-meta)
 *     ```
       add_action( 'added_post_meta', 'my_after_post_meta', 10, 4 );
       add_action( 'updated_post_meta', 'my_after_post_meta', 10, 4 );
       function my_after_post_meta( $meta_id, $post_id, $meta_key, $meta_value ){
           // check if it is the "date_from" meta key that was just updated
           if ( 'date_from' == $meta_key ) {
               // use the $meta_value to calculate 2 months in the future
               $date_to = date( 'd-m-Y', strtotime( '+2 month', strtotime( $meta_value ) ) );
               // update the "date_to" value
               update_post_meta( $post_id, 'date_to', $date_to );
           }
       }
       ```
   
 *  Thread Starter [fmalinge](https://wordpress.org/support/users/fmalinge/)
 * (@fmalinge)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/calculated-date/#post-6664722)
 * Hi,
    Thanks for your answer (and plugin) i ll try

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

The topic ‘calculated date’ is closed to new replies.

 * ![](https://ps.w.org/validated-field-for-acf/assets/icon-256x256.png?rev=1116693)
 * [Advanced Custom Fields: Validated Field](https://wordpress.org/plugins/validated-field-for-acf/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/validated-field-for-acf/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/validated-field-for-acf/)
 * [Active Topics](https://wordpress.org/support/plugin/validated-field-for-acf/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/validated-field-for-acf/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/validated-field-for-acf/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [fmalinge](https://wordpress.org/support/users/fmalinge/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/calculated-date/#post-6664722)
 * Status: resolved