getOffset()/3600; } /** * Return timezoned and formatted time * * @param int $timestamp Optional timestamp. If omitted, function will use time() * @param string $timezone Optional timezone (eg "Europe/Paris"). Default is UTC * @param string $format Optional format as what PHP's date() needs. Default it 'U' (epoch) * @return string Timezoned and formatted time */ function yourls_tzp_timezoned_timestamp($timestamp = false, $timezone = 'UTC') { $timestamp = $timestamp ? $timestamp : time(); $offset = yourls_tzp_timezoned_offset($timezone); return $timestamp + $offset * 3600; } /** * Get (string)key from array, or return false if not defined * * @param array $array Array * @param string $key Key * @return string Value of (string)$array[$key], or false */ function yourls_tzp_get_value( $array, $key, $default ) { return isset ( $array[$key] ) ? (string)($array[$key]) : $default ; } /** * Read timezone options from the DB, and return all keys or specified key * * @param string $key Key of timezone option array * @return array|mixed Array of options, or value for specified key if exists (false otherwise) */ function yourls_tzp_read_options( $key = false, $default = false ) { $options = (array)yourls_get_option( 'timezone' ); if( $key !== false ) { $options = array_key_exists($key, $options) ? $options[$key] : $default ; } return $options; }