Fix for Fix for Convert timezone from second in Drupal to WC3 standard.

doublejosh's picture
  1. // Convert timezone from second in Drupal to WC3 standard.
  2. // Starts like: "-28800" and becomes: "-08:00"
  3. $sec = substr($val, 1);
  4. $hours = intval(intval($sec) / 3600);
  5. $minutes = intval(($sec / 60) % 60);
  6. $w3cTZ = substr($val, 0, 1) .
  7.   str_pad($hours, 2, "0", STR_PAD_LEFT) .":".
  8.   str_pad($minutes, 2, "0", STR_PAD_LEFT);
  9. $val = $w3cTZ;

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.