This is the part that is responsible for random date:
//* Generate a random date between January 1st, 2015 and now
$random_date = mt_rand( strtotime( '1 January 2015' ), time() );
So you need to change it. And if you want to randomize only the time part, then this is one way to achieve that:
$random_date = strtotime( date( 'Y-m-d 00:00:00', strtotime($post->post_date) ) ) + mt_rand(0, 24*60*60);
This line will:
- take the date of post
- get only day part of it
- concert it to time
- add random number of seconds to it
So it will randomize the time of publication.
Related Posts:
- Converting Unix timestamp to wordpress date
- Count time from registration date to today
- 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
- Get system timestamp in wordpress
- Unable to select an old date in wordpress
- How to get date for each post?
- Date, Time, and Timezones
- Modify Date Format to German
- Serve visitor post time adjusted to their timezone
- Styling the date format with date_i18n
- Date and time format for UK in a custom post type [closed]
- What are the “U” and “G” time formats?
- date() returns incorrect value if used from WordPress theme, but correct otherwise
- How to get date using timezone saved in options? [duplicate]
- wordpress convert timestamp to date not correctly
- display month in french in wordpress/php?
- Set the publication date independent of the scheduled publication date
- About Time conditionals
- Format Date for Manual Insertion into post
- Translate current_time
- Display published time for today’s posts only
- convert time to WordPress user’s local time
- How to get User Time Zone in WordPress?
- Show different time stamp based on time
- Can’t convert ACF datepicker value to DateTime oject – gives me a boolean
- Can’t add to time? [closed]
- How to display Date and Time in Tamil Language?
- Get current week’s day and time outside the loop
- Use the_date with link
- automatic send email at custom time
- Change the date and time in wordpress
- Make datestamp for status updates show time
- Advanced Custom Fields and date picker, show posts only if the day is today no matter the year
- How to customize Date Format for American visitors?
- Java SimpleDateFormat for YYYY-MM-DDThh:mm:ssTZD
- 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
- The purpose of the post_date_gmt?
- Why my uploaded picture was loaded into /uploads/2015/02 not /uploads/2016/01?
- Permitting WordPress to accept dates outside of 1902-2038
- How to display date such “x ago”
- Date comparison : which date format?
- Automatically move pending posts after 30 days and, update the post date, when users update the posts
- Count days from registration date to today
- WordPress returns a wrong date
- Display date only once for a each set of posts relating to that date
- custom field value date convert to unix timestamp problems
- How to add 2 hours to the wordpress time formed with current_time(“mysql”, false)?
- Finding difference in days
- WordPress post dating – pre 1901?
- How to get time difference between publish date and now?
- Use meta_query to display events by date in custom field
- Change date from 2015/02/23 to “1 min ago”
- Display page only if user registered before a specific date
- WordPress outputs mm/dd but it should be opposite
- Individually styling date month year [closed]
- Advanced custom fields: Customise date picker’s start date (need to choose year 1500 onwards) [closed]
- timestamp and scheduled post irregularities
- Convert GMT time to local time in Gutenberg Block Editor
- How to add a sortable date column in an admin page?
- Events are all showing the current date
- Randomised Post Time
- Trouble Formatting DateTime
- Escaping date string in url with wordpress
- Separately formatting date elements
- Are there any know limitations on the date field, especially how old dates can be?
- How can I compare publish and update dates for a single post?
- Human time difference in months instead of days. How?
- Display Author Registration Date
- Local Post Date in WordPress Admin Panel Tables
- how to show date of latest post in wordpress site?
- Remove Page Timestamp via functions.php so it doesn’t show in Google Search Result Description [closed]
- Date is wrong on ‘all posts’ page
- Change News Story Layout Based on Date Range
- Switch Categories on a Specific Date?
- Randomizing Post Links Outside of Loop – No Author or Date
- wordpress built-in Jalali date convertor
- date format of custom date variable
- Display Current Date using shortcode
- Create a date archives template page for custom post type
- If X Amount of Time Has Passed Since Post Was Published, Do Something
- How to set post date in post_type so that it’s same as latest post in category
- Translate Post date (month) of china language
- WordPress wrong dates bug
- get_the_date() returns english Year & Day when language is Arabic
- Compare ACF Date field to today or yesterday
- How do you update post date (year only) in a separate custom field?
- datetime picker, timestamps and meta queries
- Display Year and Month from custom field + Age Calculator
- Display ‘modified date’ in WordPress Twenty Fourteen
- Date comparison : which date format?
- Use esc_attr() to print month name in French
- Retrieve current and localized month
- Date is showing in unreadable format. How to convert to readable date?
- Docker Container time & timezone (will not reflect changes)
- Convert custom field date format to “WordPress default”
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)