Support » Fixing WordPress » Change Date “Timestamp”
Change Date “Timestamp”
-
Give this a try
Hello Steven,
Thank you for your answer, but we dont want any more plugins if we dont need them š
Alternatively, you could create a child theme and find and recode that piece (the piece that prints the post meta data) yourself.
Effectively, you’d be making your own plugin. Code needs to be changed/overridden.
-
This reply was modified 2 years, 9 months ago by
Steven Stern (sterndata).
We have a code (find on the internet) but we dont know how to use it as an function in functions.php
<?php $date=get_the_time('d.m.Y'); $today=date('d.m.Y'); $yesterday=date('d.m.Y',strtotime("-1 days")); if($today==$date){ $date_show="Today"; }else{ if($yesterday==$date){ $date_show="Yesterday"; }else{ $date_show=$date; } } echo "$date_show"; ?>
Someone maybe know how to use it in functions.php (in the child theme)
You need to find the php file that puts the date onto a post end edit that to use your function. I like the plugin “show current template” to figure out what files are used to render a page.
Hello again Steven,
i found only that in my parent theme
/** * Post Date * * @since 1.0.0 */ function zeen_date( $pid = '', $args = array() ) { $format = get_theme_mod( 'date_format', 1 ); $time_mod = ''; $mod_date = get_the_modified_time( 'U', $pid ); $time = get_the_time( 'U', $pid ); $updated = empty( $args['updated'] ) ? '' : $args['updated']; if ( $time != $mod_date && 'on' == $updated ) { $time_mod = true; } if ( empty( $args['publish_off'] ) ) { echo '<span class="byline-part date">'; if ( ! empty( $args['icon'] ) ) { echo '<i class="tipi-i-calendar" aria-hidden="true"></i> '; } if ( ! empty( $args['sentence'] ) && 2 != $format ) { echo '<span class="byline-on byline-blog-detail">' . esc_html__( 'on', 'zeen' ) . ' </span>'; } echo '<time class="entry-date published dateCreated flipboard-date" datetime="' . esc_attr( get_the_date( 'c', $pid ) ) . '">'; switch ( $format ) { case 2: echo sprintf( esc_html__( '%1$s ago', 'zeen' ), human_time_diff( $time, current_time( 'timestamp' ) ) ); break; default: echo get_the_date( '', $pid ); break; } echo '</time>'; echo '</span>'; } if ( ! empty( $time_mod ) ) { $date = get_the_date( '', $pid ); $mod = get_the_modified_date( '', $pid ); $modified = get_the_modified_date( 'c' ); if ( $date != $mod && strtotime( $modified ) > strtotime( '-12 months' ) ) { if ( ! empty( $args['byline'] ) ) { echo '<span class="byline-part updated">'; } echo '<div class="last__updated">'; echo '<span class="last__updated__title">'; esc_html_e( 'Last updated', 'zeen' ); echo apply_filters( 'zeen_last_updated_separator', ':' ); echo '</span>'; echo '<time class="updated" datetime="' . esc_attr( $modified ) . '">'; switch ( $format ) { case 2: echo sprintf( '%1$s %2$s', human_time_diff( $mod_date, current_time( 'timestamp' ) ), esc_html__( 'ago', 'zeen' ) ); break; default: echo get_the_modified_date( '', $pid ); break; } echo '</div></time>'; if ( ! empty( $args['byline'] ) ) { echo '</span>'; } } } }
And this for comments
/** * Post Comments Block * * @since 1.0.0 */ function zeen_comment_template( $args = '', $standalone = '' ) { if ( empty( $args['ipl'] ) ) { if ( ! empty( $standalone ) ) { echo '<div class="tipi-col tipi-xs-12 standalone-comments clearfix">'; } if ( get_theme_mod( 'fb_comments' ) == 1 ) { global $post; zeen_fb_coms( $post->ID ); } else { comments_template(); } if ( ! empty( $standalone ) ) { echo '</div>'; } } else { zeen_ipl_coms( array( 'pid' => $args['pid'] ) ); } }
I dont know what to do. :/
-
This reply was modified 2 years, 9 months ago by
beat sk.
Install the plugin from my first reply and be done with it. There’s no shame in using plugins. š And making them work as WP goes forward is someone else’s headache.
-
This reply was modified 2 years, 9 months ago by
- The topic ‘Change Date “Timestamp”’ is closed to new replies.
(@beatwell)
2 years, 9 months ago
Hello,
i want to ask you people, how can i simple change the date format of actual post and comments date to “Today” and “Yesterday” and others predefined formats like before.
2.7.2020 is “Today”
1.7.2020 was “Yesterday”
But other dates will be “30.6.2020”, “29.6.2020” etc.
Thank you so much.