php

get current time in UTC

Tagged:
gmdate('Y-m-d H:i:s');

word trim

function _super6_word_trim($string, $count, $ellipsis = FALSE){
  $words = explode(' ', $string);
  if (count($words) > $count){
    array_splice($words, $count);
    $string = implode(' ', $words);
    if (is_string($ellipsis)){
      $string .= $ellipsis;
    }
    elseif ($ellipsis){
      $string .= '…';
    }
  }
  return $string;
}

convert smart quotes

function convert_smart_quotes($string)
{

// First, replace UTF-8 characters.
$string= str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$string);
// Next, replace their Windows-1252 equivalents.
$string = str_replace(
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
array("'", "'", '"', '"', '-', '--', '...'),
$string);

    return $string;
}

Syndicate content