Title: Get the release date
Last modified: April 12, 2022

---

# Get the release date

 *  Resolved [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/get-the-release-date/)
 * Hello,
 * What is the code to call the function for the release date of movie please ?
 * Exemple : <?php echo get_the__date…
 * Thanks ^^

Viewing 11 replies - 1 through 11 (of 11 total)

 *  [Kader Ibrahim S](https://wordpress.org/support/users/ibndawood/)
 * (@ibndawood)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15553855)
 * Hello there,
 * Please use this function:
 * `masvideos_template_single_movie_release_year`
 * Hope this helps. Let us know if you have any other questions or need further 
   help.
 * Thanks,
    Ibrahim
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554062)
 * I have tried
 * <?php echo get_the_movie_release_date(); ?>
 * But it doesn’t work, i would like only the year please ^^
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554282)
 * Thanks !
 * But does not work with the JustWatch script 🙁
 *     ```
       <div data-jw-widget
            data-api-key="BurbjmlQxxxxxxxxxxxxxxxxxx" 
            data-object-type="movie"
       	      data-title="<?php echo get_the_title(); ?>"
       	 data-year="<?php echo masvideos_template_single_movie_release_year(); ?>"
       	 data-offer-label="price"
       	 data-theme="dark"> 
       </div>
       ```
   
    -  This reply was modified 4 years, 1 month ago by [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/).
 *  [Kader Ibrahim S](https://wordpress.org/support/users/ibndawood/)
 * (@ibndawood)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554613)
 * Hello again,
 * Thank you for getting back. The `masvideos_template_single_movie_release_year`
   function is a template function. If you only want the release date, then you 
   can use this:
 *     ```
       global $movie;
       $movie->get_movie_release_date();
       ```
   
 * The above code should be used within the loop only.
 * Hope this helps. Let us know if you have any other questions or need further 
   help.
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554624)
 * I found an alternative through this function which is ok for me:
 *     ```
       /* Adds date to end of title 
        * @uses Hooked to 'the_title' filter
        * @args $title(string) - Incoming title
        * @args $id(int) - The post ID
        */
       function my_add_date_to_title($title, $id) {
   
           // Check if we're in the loop or not
           // This should exclude menu items
           if ( !is_admin() && in_the_loop() ) {
   
               // First get the default date format
               // Alternatively, you can specify your 
               // own date format instead
               $date_format = get_option('date_format');
   
               // Now get the date
               $date = get_the_date($date_format, $id); // Should return a string
   
               // Now put our string together and return it
               // You can of course tweak the markup here if you want
               $title .= ' (' . $date . ')';
            }
   
           // Now return the string
           return $title;
       }
   
       // Hook our function to the 'the_title' filter
       // Note the last arg: we specify '2' because we want the filter
       // to pass us both the title AND the ID to our function
       add_filter('the_title','my_add_date_to_title',10,2);
       ```
   
 * But how to replace the creation date of the article by the release date of the
   movie? ^^
 * Thanks again ♥
 *  [Kader Ibrahim S](https://wordpress.org/support/users/ibndawood/)
 * (@ibndawood)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554651)
 * Thank you for getting back. You can use the 2 lines of code that I’ve shared 
   with you earlier. It gives you the release date. You can use that in any function
   that you wish.
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15554714)
 * Oh thanks !
 * But how do I add it here?
 * data-year=”?”
 *  [Kader Ibrahim S](https://wordpress.org/support/users/ibndawood/)
 * (@ibndawood)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15557571)
 *     ```
       function masvideos_get_the_movie_release_date() {
           global $movie;
           return $movie->get_movie_release_date();
       }
   
       data-year="<?php echo esc_attr( masvideos_get_the_movie_release_date() ); ?>"
       ```
   
 * You can add the function to functions.php and then call the function in the attribute.
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15557765)
 * Thanks again!
 * The code works fine but it displays: 1975-06-20T00:00:00+01:00
 * How can I get only the year? (1975 here)
 * Thank you!
 *  [Kader Ibrahim S](https://wordpress.org/support/users/ibndawood/)
 * (@ibndawood)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15558011)
 * Please try this updated code instead:
 *     ```
       function masvideos_get_the_movie_release_year() {
           global $movie;
           return date( 'Y', strtotime( $movie->get_movie_release_date() ) );
       }
   
       data-year="<?php echo esc_attr( masvideos_get_the_movie_release_year() ); ?>"
       ```
   
 *  Thread Starter [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * (@snakedevil88000)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15558069)
 * Thanks, great support!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Get the release date’ is closed to new replies.

 * ![](https://ps.w.org/masvideos/assets/icon-256x256.jpg?rev=3151685)
 * [MAS Videos](https://wordpress.org/plugins/masvideos/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/masvideos/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/masvideos/)
 * [Active Topics](https://wordpress.org/support/plugin/masvideos/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/masvideos/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/masvideos/reviews/)

 * 11 replies
 * 2 participants
 * Last reply from: [snakedevil88000](https://wordpress.org/support/users/snakedevil88000/)
 * Last activity: [4 years, 1 month ago](https://wordpress.org/support/topic/get-the-release-date/#post-15558069)
 * Status: resolved