Display page only if user registered before a specific date

This is a basic function to get the current user and compare it with a custom DateTime to see if the user registered earlier or later: function wpse_219284_registered_before( $date_time ) { $user = wp_get_current_user(); $registered_before = false; if ( $user instanceof WP_User ) { $registered = new DateTime( $user->data->user_registered ); $limit = new DateTime( $date_time … Read more

Change date from 2015/02/23 to “1 min ago”

Here you go. This goes in functions.php This changes the time on your website everywhere. Now you can keep using <?php echo get_the_date(); ?> in your loop or theme files. // Relative date & time function wpse_relative_date() { return human_time_diff( get_the_time(‘U’), current_time( ‘timestamp’ ) ) . ‘ ago’; } add_filter( ‘get_the_date’, ‘wpse_relative_date’ ); // for … Read more

Page Revision date displaying on google search

So I finally figured out how to remove the dates displayed on my pages within a google search, turns out there was a hidden span tag on all of my pages that google was using to get the date All I had to do was find the code that added that hidden span tag to … Read more

the_modified_date returns published date

I think that you are using Parsidate plugin to convert dates to Hijri date. The plugin since the current version(2.2.2) returns the published date for both the_date and the_modified_date functions. This is a bug that i reported it to them. For now, you can use the wp-jalali plugin instead, that solved the problem for me.

Styling the date format with date_i18n

Just use date_i18n in multiple places with PHP date arguments just for what you need: if ( $date = get_post_meta( $thepostid, ‘_sale_price_dates_to’, true ) ) { $sale_price_dates_to = ‘<span class=”m”>’ . date_i18n( ‘M’, $date ) . ‘</span> ‘ . ‘<span class=”d”>’ . date_i18n( ‘j’, $date ) . ‘</span> ‘ . ‘<span class=”y”>’ . date_i18n( ‘Y’, … Read more

WordPress post dating – pre 1901?

This is something totally new to me, so I did some research. What an exciting question! I had a look at the how WP saves the date when a post is saved. WP runs post date through wp_checkdate(), which uses PHP native function checkdate(). According to the PHP docs checkdate() considers any year between 1 … Read more

Remove “at” string from wordpress comment date

Most likely, the ‘at’ is coming from the value of $comment->comment_date. If that is the case, and since we have to do with string, you could pass it from str_replace first, in order to remove the ‘ at’, like: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( ‘d M Y’, strtotime( str_replace(” at”, “”, … Read more

Count days from registration date to today

I am using this answer from StackOverflow as a basis which using functions from PHP 5.2.2 The main issue is that human_time_diff() doesn’t always return days, nor does it have a parameter on what to return. This function just returns how long they have been registered, whether it’s days, weeks, months, or years. I believe … Read more

month name translation

Use date_i18n(): date_i18n( ‘Y. F j.’, strtotime( get_the_time( “Y-m-d” ) ) ); From the function’s description: Retrieve the date in localized format, based on timestamp. If the locale specifies the locale month and weekday, then the locale will take over the format for the date. If it isn’t, then the date format string will be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)