Notifications
Clear all

Date Formatting Update Regarding Caching Problems

13 Posts
4 Users
4 Reactions
925 Views
Tutrix
Posts: 1496
(@tutrix)
Noble Member
Joined: 5 years ago

@spielo 

I have now tested the code, unfortunately it currently shows the wrong time
e.g. 12:55 instead of 13:55
I am currently looking for the solution how or where to insert the (+1 hour) 😀 

Reply
3 Replies
(@spielo)
Joined: 2 years ago

Eminent Member
Posts: 16

@tutrix 

is fixed with this update: 

<p class="postuser">
    <?php wpforo_phrase( 'by' ) ?> <?php wpforo_member_link( $member ) ?>,
    <span class="uncached" style="white-space: nowrap;">
        <?php
        $last_post_date = date("Y-m-d", strtotime($post['created'] . '+1 hour'));
        $current_date = date_i18n('Y-m-d');

        if ($last_post_date === $current_date) {
            echo esc_html__( 'heute um ', 'text-domain' ) . date_i18n('H:i', strtotime($post['created'] . '+1 hour'));
        } elseif ($last_post_date === date_i18n('Y-m-d', strtotime("-1 day"))) {
            echo esc_html__( 'gestern um ', 'text-domain' ) . date_i18n('H:i', strtotime($post['created'] . '+1 hour'));
        } else {
            echo esc_html__( 'am ', 'text-domain' ) . '<div class="full-date">' . date_i18n('d/m/Y, H:i', strtotime($post['created'] . '+1 hour')) . '</div>';
        }
        ?>
    </span>
</p>
Reply
Tutrix
(@tutrix)
Joined: 5 years ago

Noble Member
Posts: 1496

@spielo 

Yes, that's how it works, thank you very much 😀 

Reply
(@spielo)
Joined: 2 years ago

Eminent Member
Posts: 16

i have also updated in theme, we use style 2 forum.php

	<p class="wpforo-last-post-author">
    <?php wpforo_member_link($member, ''); ?><span class="wpforo-date wpforo-date-ago">, <?php 
    $last_post_date = date("Y-m-d", strtotime($forum['last_post_date'] . '+1 hour'));
    $current_date = date_i18n('Y-m-d');

    if ($last_post_date === $current_date) {
        echo esc_html__( 'heute um ', 'text-domain' ) . date_i18n('H:i', strtotime($forum['last_post_date'] . '+1 hour'));
    } elseif ($last_post_date === date_i18n('Y-m-d', strtotime("-1 day"))) {
        echo esc_html__( 'gestern um ', 'text-domain' ) . date_i18n('H:i', strtotime($forum['last_post_date'] . '+1 hour'));
    } else {
       echo esc_html__( 'am ', 'text-domain' ) . date_i18n('d/m/Y H:i', strtotime($forum['last_post_date'] . '+1 hour'));
    }
    ?></span>
</p>

and for style 2 topic.php

<div class="wpforo-last-post"><span class="wpforo-last-post-author"><?php wpforo_member_link($last_post_member, ''); ?><span class="wpforo-date wpforo-date-ago">, <?php
        $last_post_date = date("Y-m-d", strtotime($last_post['created'] . '+1 hour'));
        $current_date = date_i18n('Y-m-d');

        if ($last_post_date === $current_date) {
            echo esc_html__( 'heute um ', 'text-domain' ) . date_i18n('H:i', strtotime($last_post['created'] . '+1 hour'));
        } elseif ($last_post_date === date_i18n('Y-m-d', strtotime("-1 day"))) {
            echo esc_html__( 'gestern um ', 'text-domain' ) . date_i18n('H:i', strtotime($last_post['created'] . '+1 hour'));
        } else {
            echo esc_html__( 'am ', 'text-domain' ) . date_i18n('d/m/Y H:i', strtotime($last_post['created'] . '+1 hour'));
        }
        ?></span>
    </span>
</div>

by the way, i do not find any way at the moment how i safe the widgtes code outside the plugin that is still work after wpforo plugin have a update, with theme is no problem if you move too wp-theme folder.

Reply
BlackRaz
Posts: 404
Admin
(@blackraz)
Contributor
Joined: 8 years ago

Hi  @spielo ,  @tutrix ,  @dimalifragis 

It's not recommended to use the provided customization as it may lead to conflicts with timezones and show incorrect date and time for users in different timezones. Regarding saving the custom Recent widget and protecting it from wpForo updates, you should consider creating your own custom widget with a different name.

You can refer to detailed documentation on creating a custom WordPress widget here: [How to Create a Custom WordPress Widget]

This approach will help you achieve the desired functionality without risking conflicts and issues during updates.

Reply
2 Replies
(@spielo)
Joined: 2 years ago

Eminent Member
Posts: 16

@blackraz 

Thanks for the info, I tested the code and didn't find a problem, but never now, that's why I'm releasing the code here for everyone to test it themselves or even the developers if they have any thoughts about the time format.

your link doesn't work on follow a 404 page, anyway I have some customer widgets, the only question is the actual content, like RecentPost.php is still overwritten during an update? It is its own PHP file and has nothing to do with the widgets in Wordpress

Reply
BlackRaz
Admin
(@blackraz)
Joined: 8 years ago

Contributor
Posts: 404

@spielo

I have updated the previous message, and now the link should work. Additionally, any customized wpForo code file inside the /wp-content/plugins/wpforo/ directory will be lost during each update. Therefore, we recommend creating your own new widget with a new name using your customized .php files.

Reply
Page 2 / 2