How to add more cities on Timezone?

How do I add more cities on booking timezone? Also, can I make it timezones (e.g. GMT time or EST time) instead of cities?

Thanks for bringing this up. Very important. So many cities are unavailable and it is super time consuming to research which cities timezone match with the cities already available.

We use this core PHP function to get a list of timezones, it’s not defined by HivePress PHP: timezone_identifiers_list - Manual I guess they list capital cities or state capitals. It may be possible to add new items to the drop-down, but via the code snippets only.

Any code snippets available to do this manually?

Please try this PHP snippet, but please note that it can require further customization. The provided snippet only adds an option to the timezone selection field, but it does not guarantee that it will work in timezone conversion functionality, so it requires additional testing. Because there is a list of supported timezones in PHP PHP: List of Supported Timezones - Manual that are used for the timezone conversion functionality, making changes here requires advanced customization. If you are not familiar with the code customization then please consider hiring someone for custom work https://fvrr.co/32e7LvY

add_filter(
	'hivepress/v1/fields/select',
	function($field_args, $field){
		
		if('booking_timezone' === hivepress()->helper->get_array_value($field_args, 'name', '')){
			$field_args['options']['custom_timezone'] = 'Custom timezone';
		}
		
		return $field_args;
	},
	1000,
	2
);
1 Like

Is it possible to use the GMT, EST, PST, MST etc, rather than using the cities?

Yes, you can replace the whole array using the snippet above, but there’s no such built-in options yet, we just fetch a list of timezones provided by PHP PHP: timezone_identifiers_list - Manual

Hi @ihor I used this code but still have not achieved my goals. Two questions:

  1. Is it possible to wipe out all the existing cities provided by PHP PHP: timezone_identifiers_list - Manual and manually add custom cities?

  2. How can I order the manually added cities so they should show at the top of the drop-down menu? Can you send an updated snippet?

Thanks.

Yes, you can try setting a completely custom list this way:

add_filter(
	'hivepress/v1/fields/select',
	function($field_args, $field){
		
		if('booking_timezone' === hivepress()->helper->get_array_value($field_args, 'name', '')){
			$field_args['options'] = [
				'custom_timezone' => 'Custom timezone',
				'another_timezone' => 'Another timezone',
			];
		}
		
		return $field_args;
	},
	1000,
	2
);

Note that the list keys should match any of the supported PHP timezones.

Hi @ihor thank you. I checked the list of php supported websites from PHP Timezones and i got this result. See screenshot.

Notice that all the available php timezones are city or state names. However, I would like to have the est, pst timezones on my website. See screenshot.

My question is, since my custom list of timezones are not available on the php, what are the actual consequences this will have on my website? Thanks

PHP covers all the available timezones, but labels may be different. Using the code snippet above, you can set PHP timezones (from the supported list) but set any custom labels on the right, that are more suitable for your site.

I just realised it wouldn’t publish any listing with the custom timezones i set. When i upload a listing on frontend, it works well. When I go to backend to confirm and publish the listing, i realise that all the custom timezones i had added are unavailable.

Any workaround?

Hi,

Unfortunately, there’s no such feature; it would require advanced customizations.
If customizations are required for your site, please try customizing it using the collection of code snippets Search · user:hivepress · GitHub and other developer resources, or consider hiring someone for custom work https://fvrr.co/32e7LvY.

So what you are saying is, it is basically impossible to add any custom timezones not found on php list?

It’s possible, but this requires customizations, unfortunately there’s no such option in the back-end UI in the current version. Sometimes we share simple code snippets if available, but in this case further customizations are required, which are beyond our support scope unfortunately (it includes fixing bugs in the HivePress features, and guidance about its features - this way we guarantee the advertised features).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.