• Hello, I can’t import a CPT datetime field.

    I have this field called “date-match”, which is, according to JetEngine, type “datetime-local”.

    This is the string I try to import: 2021-10-13 00:00
    I’ve also tried: 2021-10-13 00:00:00
    And: 2021-10-13T00:00
    Not even: 2021-10-13T00:00:00

    Sadly, it always come as “1970-01-01T00:00”.

    I’ve tried to substitute hyphens to slashes, no success.

    Is it because of JetEngine’s datetime type? I’ve tried to change from datetime to date, and not working too.

    Is there any workaround this?

    From what I’ve searched, the “date_create()” function is used on this. Maybe if I edit used function directly in the plugin source code?

    • This topic was modified 3 years, 1 month ago by victorpietro.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Takuro Hishikawa

    (@hissy)

    I already wrote some examples to modify data on importing on the plugin page. Please check.

    Thread Starter victorpietro

    (@victorpietro)

    Hi @hissy, thank you for the quick answer… I couldn’t find these examples that you’ve mentioned, would you mind sharing any link for that please?

    Plugin Author Takuro Hishikawa

    (@hissy)

    Thread Starter victorpietro

    (@victorpietro)

    Hi @hissy, I was able to make it work following one of your codes. Thank you for your time and brilliant plugin.

    For anyone wondering, here is what I’ve done:

    
    // add this to your theme's functions.php
    function really_simple_csv_importer_save_meta_filter( $meta, $post, $is_update ) {
    	// datetime to timestamp
    	if (isset($meta['_date_meta_field'])) {
    		$meta_date = $meta['_date_meta_field'];
    		$date = strtotime($meta_date);
    		$meta['_date_meta_field'] = $date;
    	}
    	
    	return $meta;
    }
    add_filter( 'really_simple_csv_importer_save_meta', 'really_simple_csv_importer_save_meta_filter', 10, 3 );
    
    • This reply was modified 3 years, 1 month ago by victorpietro.
    Plugin Author Takuro Hishikawa

    (@hissy)

    Thanks to share really useful code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Import not working on a CPT datetime field’ is closed to new replies.