Title: Default datetimes in repeatable fields
Last modified: December 10, 2022

---

# Default datetimes in repeatable fields

 *  Resolved [Patrick Johanneson](https://wordpress.org/support/users/pjohanneson/)
 * (@pjohanneson)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/default-datetimes-in-repeatable-fields/)
 * I’ve got a need for a repeatable `text_datetime_timestamp` field, and I’d like
   to set the default to “today + a month”. In my code, I have:
 *     ```
       $cmb2->add_field(
       	array(
       		'id' => 'my_prefix_showtime',
       		'name' => __( 'Showtimes', 'my-custom-post' ),
       		'type' => 'text_datetime_timestamp',
       		'repeatable' => true,
       		'default' => time() + MONTH_IN_SECONDS,
       	)
       );
       ```
   
 * This works fine for the first new date (it shows up as a formatted date a month
   in the future); however, any future fields get what appears to be the raw `time()
   + MONTH_IN_SECONDS` output.
 * Is there any way to ensure that _every_ datetime field in the `repeatable` box
   gets a valid date?

Viewing 1 replies (of 1 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [3 years, 5 months ago](https://wordpress.org/support/topic/default-datetimes-in-repeatable-fields/#post-16281797)
 * When you say raw output, you mean literally this string? `time() + MONTH_IN_SECONDS`
   instead of an actual timestamp?

Viewing 1 replies (of 1 total)

The topic ‘Default datetimes in repeatable fields’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/default-datetimes-in-repeatable-fields/#post-16281797)
 * Status: resolved