Here is how it works for me with minor changes:
global $post;
$post_created = strtotime($post->post_date);
$sixMonthsAgo = strtotime('-6 months');
$human_time="hace ". human_time_diff( get_the_time('U'), current_time('timestamp') );
$mobile = wp_is_mobile();
if ($post_created > $sixMonthsAgo && $mobile) {
the_time('j. M .Y');
} elseif( $post_created > $sixMonthsAgo && !$mobile) {
the_time('j. F .Y');
} else {
echo $human_time;
}
I hope this simplification helps 🙂
Related Posts:
- Converting Unix timestamp to wordpress date
- wordpress convert timestamp to date not correctly
- Count time from registration date to today
- Update existing post times to random times?
- Timezone for Plugin
- How to get Unix Local Time?
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- Make datestamp for status updates show time
- Get system timestamp in wordpress
- How to get current timestamp in string format in Java? “yyyy.MM.dd.HH.mm.ss”
- Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
- How do I use PHP to get the current year?
- Convert a Unix timestamp to time in JavaScript
- Convert number to month name in PHP
- Post doesn’t show date if there’s another post with the same date
- Unable to select an old date in wordpress
- How to get date for each post?
- The purpose of the post_date_gmt?
- Why my uploaded picture was loaded into /uploads/2015/02 not /uploads/2016/01?
- How to integrate get_post_time with date_i18n function?
- Permitting WordPress to accept dates outside of 1902-2038
- How to show the real post date in a draft
- Add 20yrs to post date, and then query
- Date comparison : which date format?
- Modify Date Format to German
- XML export posts from one single day
- Bulk edit post date in wordpress
- Automatically move pending posts after 30 days and, update the post date, when users update the posts
- Count days from registration date to today
- Display date only once for a each set of posts relating to that date
- WordPress post dating – pre 1901?
- Styling the date format with date_i18n
- the_modified_date returns published date
- Page Revision date displaying on google search
- Change date from 2015/02/23 to “1 min ago”
- Display page only if user registered before a specific date
- Date and time format for UK in a custom post type [closed]
- Display post date as 04/26/2013
- Individually styling date month year [closed]
- How to get date using timezone saved in options? [duplicate]
- Show post updated date instead of published
- Set the publication date independent of the scheduled publication date
- Add a link to display posts with a specific tag within a date range
- Mini app that shows one unique quote each day. 56 rotating posts rotating for each themed weekday. It works, but I need your advice
- How to add a sortable date column in an admin page?
- Events are all showing the current date
- Update all comments time to random dates?
- Do multiple jobs on date change without WordPress cron job
- Escaping date string in url with wordpress
- Is there anything special I have to think of when setting post_date_gmt when inserting a new post?
- Format Date for Manual Insertion into post
- Wrong date returned by get_the_time
- Get_the_date doesnt show todays date [closed]
- Translate current_time
- Are there any know limitations on the date field, especially how old dates can be?
- Conditional: IF post creation date is in the first half OR last half of the year [closed]
- Return date in French
- convert time to WordPress user’s local time
- How to get User Time Zone in WordPress?
- Display Author Registration Date
- How display modified date of most recent modified post in wordpress?
- Date Language doesn’t change
- Sort / display recent posts by publish date
- display future posts in date page
- how to show date of latest post in wordpress site?
- Month display in English but required in Swedish?
- Remove Page Timestamp via functions.php so it doesn’t show in Google Search Result Description [closed]
- Show different time stamp based on time
- Update post date of page when Visitor access that page?
- Switch Categories on a Specific Date?
- Is it possible to change X Hours Ago to date in WP Admin?
- Display Current Date using shortcode
- Check if is Post or Comment
- Create a date archives template page for custom post type
- changing type of date picker in contact form 7 date picker plugin
- Get current user last post date
- I want to format my Post dates differently to other dates on my website
- Change pubDate in rss feed in another format
- Can’t convert ACF datepicker value to DateTime oject – gives me a boolean
- How to add published date in product [closed]
- Can’t add to time? [closed]
- How to hide post published date?
- Get current week’s day and time outside the loop
- Notify after 3,6,9 and then 12 months after plugin activation
- suffix title with “EXPIRED” when scheduled post has reached it’s published date
- Display ‘modified date’ in WordPress Twenty Fourteen
- automatic send email at custom time
- Set Custom Date for Posts
- Posted date format not reflected
- check if a draft has been moved there from publish to draft
- Date comparison : which date format?
- Advanced Custom Fields and date picker, show posts only if the day is today no matter the year
- Use esc_attr() to print month name in French
- Retrieve current and localized month
- wp_date doesn’t work
- How to get the date of all blog posts
- In my Website homepage I want to remove date which is written along author name [closed]
- get_the_date() return always UTC+0 [duplicate]
- Docker Container time & timezone (will not reflect changes)
- How to customize Date Format for American visitors?