Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @urbelab

    There are a number of different ways you could do this, but here’s a quick and easy example function:

    [strtok({initial_registration[1]},"-")]

    Thread Starter urbelab

    (@urbelab)

    Great and simple solution @wpallimport ! Thanks!
    Just another question please. Could I use it for extract from same date (2016-03-01T00:00:00) a date format like this 2016-03 or 03-2016?
    Thanks in advance for you answer

    EDIT: I’ve found this shortcode for first part of my question: [substr({initial_registration[1]},"0","-12")]
    With this code I have a perfect 2016-03 text in my post content.
    Now it would be perfect for me to find a way to turn it into 03-2016.
    Is there a way to do everything with a shortcode or do I have to insert a function in the prepared editor?

    Plugin Author WP All Import

    (@wpallimport)

    Hi @urbelab

    I would suggest a custom function for this, for example:

    function my_get_custom_date( $date ) {
    	$time = strtotime( $date );
    	return date( "m-Y", $time );
    }

    Though, you could still do it with one line:

    [date("m-Y",strtotime({initial_registration[1]}))]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to extract year from a xml attribute’ is closed to new replies.