Add one day to get_the_date in Wordpress

get_the_date( $format)
get_the_date in wp
wordpress get current date
strtotime
get the date function
wordpress show post date
wordpress get_date
fetch post publish date

In the WPTouch theme, the posting date is displayed in a large bubble. However, posts are added the night before, so the day is behind by one. To fix this, I changed this line:

<?php wptouch_the_time( 'j' ); ?>

to this:

    <?php
            $date = DateTime::createFromFormat('m-d-Y', mysql2date('m-d-Y', $post->post_date));
            $date->modify('+1 day');
            echo $date->format('j');
    ?>

This works, but is crazy ugly. I think there should be a better way to get from mysql date to php DateTime.

You can use this filter to modify the date before it is given to the theme with the function get_the_date() (which wptouch_the_time() most probably uses to get the date):

add_filter( 'get_the_date', 'modify_get_the_date', 10, 3 );
function modify_get_the_date( $value, $format, $post ) {
    $date = new DateTime( $post->post_date );
    $date->modify( "+1 day" );
    if ( $format == "" )
        $format = get_option( "date_format" );
    return( $date->format( $format ) );
}

That being said, instead of modifying the date when it is read from the database, it would be better to just store the publication date when it is written. You can do this by scheduling posts for the next day, instead of publishing them directly.

get_the_date() | Function, get_the_date( string $format = '', int|WP_Post $post = null ) Log in to add feedback Gets the date format in day, day symbol, short month and long year. For Front End Designers: Use this to simply display the month day, year (April 20, 2020) and then style the date with css using .entry-date. — By aryon — 7 months ago Log in to add feedback

you can do this

<?php
$date=date_create();
date_modify($date,"+1 month");
echo date_format($date,"Y-m-d");
?>

the_date() | Function, Adding the date and time to the WordPress Loop seems like a simple the date for subsequent posts published on the same day as a previous one. The simplest option is to replace the_date() with echo get_the_date() . php - Add one day to get_the_date in Wordpress - Stack Overflow In the WPTouch theme, the posting date is displayed in a large bubble. However, posts are added the night before, so the day is behind by one. To fix this, I changed this line: &lt;?php wptouch_th

The way i always do this is using the strtotime method

<?php 
$format = ""; // your date format
$oneDayLater = strtotime("+1 day", strtotime($columnValue));
$out = date($format, $oneDayLater);
?>

Displaying the Date and Time in the WordPress Loop, You'll have to use the proper date format string (as used in PHP date function) in the WordPress get_the_date() function's first parameter. Will only output the date if the current post’s date is different from the previous one output. i.e. Only one date listing will show per day worth of posts shown in the loop, even if the function is called several times for each post. HTML output can be filtered with ‘the_date’. Date string output can be filtered with ‘get_the_date’.

How to get year, month and hour in Wordpress?, “wordpress get post date day from get_the_date” Code Answer INSTALL GREPPER FOR CHROME Dynamic Carousel in Laravel not working displays only one image � E: Couldn't find any package by regex 'php7.2-json'� Add Days to Wordpress get_the_date function. Ask Question Asked 4 years ago. Active 4 years ago. Viewed 507 times 0. 1. I need to add an expiry date to an xml feed

wordpress get post date day from get_the_date Code Example, In WordPress, the date and time are retrieved and displayed using template tags, d, The numeric day of the month with leading zeros, 01 – 31. As the name suggests, it allows you to add a clock and the date to your WordPress website. Their time and date widget offers lots of customization options. You can choose between a 12 or 24-hour cycle, whether to update the clock every minute or second, show or hide the date and determine their order.

How to format the date and time in WordPress, Maybe you wanted to abbreviate the month or hide the year or be to edit your WordPress theme by creating a child theme and add this line� Once you add the code, you can use the [datetoday] shortcode in the WordPress Editor or Divi Code Module: And it will show the current date on the front-end following the format in your WordPress settings: You can also add basic formatting to your dates by using the TinyMCE Editor.

Comments
  • I'd rather use the correct date in WordPress (by scheduling the post for the next day instead of publishing it directly)
  • stackoverflow.com/questions/14460518/…
  • Well, the less correct version would be to use date and strtotime: echo date('j', strtotime($post->post_date . ' +1 day'));
  • For more than 1 day to add how it should be