Home Forums Backend Issues (wp-admin) Get years below 1917 to show on date field select box


Get years below 1917 to show on date field select box

  • I’m using date field to select date for an historical event. Right now field only allows me to select down to year 1917 (which I’m guessing is 2017 – 100).

    How can I change that range? I don’t see any options in the field configuration panel.

  • This is probably something to do with the datepicker. You need to see this page about adding custom javascript to acf, see the section on date and time picker args and this documentation on the datepicker that will tell you what the arguments are

  • Use the appropriate hook


    function my_admin_enqueue_scripts() {
    	wp_enqueue_script( 'date-picker-js', get_template_directory_uri() . '/js/custom_date_picker.js', array(), '1.0.0', true );
    add_action('admin_enqueue_scripts', 'my_admin_enqueue_scripts');


    // function to merge two Javavascipt objects IE compatible, from prototype.js
    function extend(destination, source) {
    	for (var property in source)
    		destination[property] = source[property];
    	return destination;
    // Acf hook -> Hooks -> Filters -> date_picker_args
    // see
    acf.add_filter('date_picker_args', function( args, $field ){
    	// do something to args
    	var custom_args = {
    	  yearRange:			"-200:+100", // value to change
    	args = extend(args, custom_args)
    	// return
    	return args;
  • I have the same need of saving historic dates (down to 17th century).

    I used the script that @aminta wrote and it allows the user to select the historic date fine, and the date is saved correctly to the DB (Jan 1, 1700 is ‘17000101’ on DB)

    But when I edit the post (on backend) I get the default date of today instead of the saved date of Jan 1, 1700…

    How can I fix this?

  • For the JS to work you’ll need to enqueue after loading ACF.

    wp_enqueue_script( 'date-picker-js', get_stylesheet_directory_uri() . '/js/custom_date_picker.js', array('acf-input'), '1.0.0', true );

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Get years below 1917 to show on date field select box’ is closed to new replies.