Title: Random dates: add specific time?
Last modified: July 5, 2019

---

# Random dates: add specific time?

 *  Resolved [fsdfbsidfgbsid](https://wordpress.org/support/users/fsdfbsidfgbsid/)
 * (@fsdfbsidfgbsid)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/random-dates-add-specific-time/)
 * First off excellent plugin. When setting the post dates randomly between certain
   times, is it possible to specify a specific time of the day? Currently it seems
   you can only pick the days.

Viewing 1 replies (of 1 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/random-dates-add-specific-time/#post-11727117)
 * Hi [@fsdfbsidfgbsid](https://wordpress.org/support/users/fsdfbsidfgbsid/)
 * > When setting the post dates randomly between certain times, is it possible 
   > to specify a specific time of the day?
 * Not within our UI, but you could do it with a custom PHP function: [http://www.wpallimport.com/documentation/advanced/execute-php/](http://www.wpallimport.com/documentation/advanced/execute-php/).
   Here’s an example function:
 *     ```
       function my_get_random_date( $start, $end, $time ) {
       	$start = strtotime( $start );
       	$end = strtotime( $end );
       	$random_date = mt_rand( $start, $end );
       	$final_date = date( "Y-m-d", $random_date ) . " " . $time;
       	return $final_date;
       }
       ```
   
 * Example usage:
 * `[my_get_random_date("2019-07-01","2019-07-12","12:00:00")]`
 * This would be used in the “As specified” field: [https://d.pr/i/8Ndq4q](https://d.pr/i/8Ndq4q).
 * Keep in mind that there’s no error checking in the example, so you have to use
   proper date/time formats or modify the code.

Viewing 1 replies (of 1 total)

The topic ‘Random dates: add specific time?’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/random-dates-add-specific-time/#post-11727117)
 * Status: resolved