×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Vlad Krasovsky
Added: Oct 22, 2014 10:11 PM
Views: 1841
Tags: no tags
  1.         public static function includeTimeConverterJS(){
  2.             $fuzz = fuzzFramework::getInstance();
  3.            
  4.             $output = $fuzz->assets->getUrl("tzDetect.js", array("cityvibe","timeZones"));
  5.             echo <<<HEREDOC
  6.             <script type="text/javascript" src="{$output}"></script>
  7. HEREDOC;
  8.            
  9.            
  10.             $output = $fuzz->assets->getUrl("moment.js", array("cityvibe","timeZones"));
  11.             echo <<<HEREDOC
  12.             <script type="text/javascript" src="{$output}"></script>
  13. HEREDOC;
  14.              $output = $fuzz->assets->getUrl("moment-timezone.js", array("cityvibe","timeZones"));
  15.             echo <<<HEREDOC
  16.             <script type="text/javascript" src="{$output}"></script>
  17. HEREDOC;
  18.              $output = $fuzz->assets->getUrl("timeConverter.js", array("cityvibe","timeZones"));
  19.             echo <<<HEREDOC
  20.             <script type="text/javascript" src="{$output}"></script>
  21. HEREDOC;
  22.            
  23.            
  24.         }
  25.        
  26.         /**
  27.          * function converts server time into client time
  28.          * CALCULATES GMT TIME!
  29.          * PST 0 = GMT-8   <==> GMT-0 = PST+8
  30.          * @param type $optionsArr -- !required $optionsArr["timeValue"]
  31.          * otherwise will convert from current server time
  32.          * if $optionsArr["format"] is set -> will convert time to this format
  33.          * @return time
  34.          */
  35.         public static function clientDateTime($optionsArr = array()){
  36.             $fuzz = fuzzFramework::getInstance();
  37.             require_once("{$fuzz->config->get(fuzzConfig::TYPE_PATH_BASE)}/lib/classes/timeConverter.php");
  38.            
  39.             //$dt = timeConverter::getServerTime();
  40.            
  41. //            $clientTimeZone = $_COOKIE["client-timezone-offset"];
  42. //            $offsetTime = 0;
  43. //            if(!empty($clientTimeZone)){
  44. //                $offsetTime = timeConverter::get_timezone_offset($clientTimeZone);
  45. //            }        
  46. //
  47.             if (!empty($optionsArr["timeValue"])){
  48.                 $timeValue = $optionsArr["timeValue"] ;//- $offsetTime;
  49.             }
  50.             else {
  51.                 $timeValue = time() ;//- $offsetTime;
  52.             }
  53.            
  54.             if(!empty($optionsArr["format"])){
  55.                 $timeValue =  date($optionsArr["format"],$timeValue);
  56.             }
  57.            
  58.             $timeString = <<<HEREDOC
  59.                 <span name='cityvibeUtils_timestamp'
  60.                     data-timestamp='{$optionsArr["timeValue"]}' data-time-format='{$optionsArr["format"]}'>
  61.                         {$timeValue}
  62.                 </span>  
  63. HEREDOC;
  64.            
  65.            
  66.             return $timeString;
  67.            
  68.         }