Twit

How to get time of all timezones in PHP
How to get time of all timezones in PHP

To get an array of all time zones with their time offset from Greenwich, use the following function:

function get_time_timezones()
{
	$zones_array = array();
	$timestamp = time();
	
	$default_timezone = date_default_timezone_get();
	$timezone_list = timezone_identifiers_list();
	
	foreach ($timezone_list as $zone)
	{
		date_default_timezone_set($zone);
		$zones_array[$zone] = date('P', $timestamp);
	}
	
	date_default_timezone_set($default_timezone);
	
	return $zones_array;
}

read more...

How to set default parameters for a widget in Yii2
How to set default parameters for a widget in Yii2

To set default parameters for a widget in Yii2, you need to use the dependency injection container.

Example with DatePicker:

Yii::$container -> set('yiijuiDatePicker', [
	'language' => 'en-US',
]);

The first parameter in set is the class name, and the second is the array of parameters to configure. This way, we can preconfigure our widget properly from the start.

How to find out tomorrow's or yesterday's date in timestamp format in PHP?
How to find out tomorrow's or yesterday's date in timestamp format in PHP?

To get yesterday’s or tomorrow’s date in timestamp format (PHP), you need to use the standard PHP function "strtotime".

For example, let’s display the time of the current date at 00:00:00 (zero hours, zero minutes, zero seconds):

$t = strtotime('00:00:00');
echo 'Timestamp: '.$t;
echo 'Datetime: '.date('Y-m-d H:i:s',$t);

read more...