Latest Tweets:

Quick timezone format converter (Drupal to WC3)

// Convert timezone from second in Drupal to WC3 standard
function timezoneConvert($val, $toSeconds = false) {
  if(!$toSeconds) {
    // Starts like: "-28800" and becomes: "-08:00"
    $sec = substr($val, 1);
    $hours = intval(intval($sec) / 3600);
    $minutes = intval(($sec / 60) % 60);
    $w3cTZ = substr($val, 0, 1) .
      str_pad($hours, 2, "0", STR_PAD_LEFT) .":".
      str_pad($minutes, 2, "0", STR_PAD_LEFT);
    return $w3cTZ;
  }
  else {
    $seconds = 0;
    $units = explode(':',$val,2);
    $seconds += $units[0] * 3600; // Hours
    $seconds += $units[1] * 60; // Minutes
    return $seconds;
  }
}  
http://drupal.stackexchange.com/a/19384/1117