• Resolved Patrick Johanneson

    (@pjohanneson)


    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

    (@tw2113)

    The BenchPresser

    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.