WP Customer Reviews – Change Default Timezone


WP Customer Reviews is a great plugin. It allows you to setup a specific page on your blog to receive customer testimonials for your business/service OR to write reviews about a product. When a review is submitted, the title includes a name @ timezone.

I noticed that the timezone didn’t match the timezone I selected in my WordPress settings. This plugin is using UTC time while the rest of my site is using the localized timezone. My goal was to dynamically find the user timezone when they submit a review and have it included in the title of their review.

This following code converts a GMT date into the correct format for the review:

get_date_from_gmt( string $string, string $format = 'Y-m-d H:i:s' )  
// $string = The date to be converted
// $format(string)= (Optional) The format string for the returned date (default is Y-m-d H:i:s)
// We are changing it into 'm/d/Y H:i:s' 

// I changed the Original Code in wp-customer-reviews-3.php:
// FROM:
$datetime = date('m/d/Y h:i');
return "{$fname} @ {$datetime}";

// TO:
$datetime = date('m/d/Y h:i'); // Keep the original code
$localtime = get_date_from_gmt($datetime,'m/d/Y H:i:s' );
return "{$fname} @ {$localtime}";

After this simple change, if someone submits a review, it reflects the correct local timezone.

Leave a Reply

Your email address will not be published. Required fields are marked *