Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public static function getLocaleTime($dateTime,$dateFormat)
  2. {
  3. $localTimeZone = 'America/Los_Angeles';
  4. $userKey = Account::getUserKey();
  5.  
  6. if (!empty($userKey)){
  7.  
  8. require_once ('logFile.class.php');
  9. $logFile = new LogFile();
  10. $logFileName = '_u';
  11. $database = self::getConnection();
  12. $userInfo = array();
  13. try {
  14. $query = "SELECT timezone FROM teelaunch_accountUsers WHERE userKey = :userKey LIMIT 1";
  15. $database->query($query);
  16. $database->bind(":userKey", $userKey);
  17. $userInfo = $database->resultsFromDB();
  18.  
  19. $userInfo = (!empty($userInfo)) ? current($userInfo) : array();
  20.  
  21. } catch (PDOException $e){
  22. $logFile->writeToLogFile('DB Error on account.php for userKey:' . $userKey . '; message:' . $e->getMessage() . '',
  23. $logFileName);
  24. }
  25.  
  26. $database = null;
  27. $localTimeZone = $userInfo['timezone'];
  28.  
  29. }
  30. $date = new DateTime($dateTime . ' +00');
  31. try {
  32. $date->setTimezone(new DateTimeZone($localTimeZone));
  33. } catch(Exception $e){
  34.  
  35. if (empty(self::$error)){
  36. self::$error = 'Please make sure that you have set your timezone on the <a href="/account/">account page</a><br>';
  37. echo self::$error;
  38. }
  39.  
  40.  
  41. }
  42.  
  43. return $date->format($dateFormat);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement