Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getLocaleTime($dateTime,$dateFormat)
- {
- $localTimeZone = 'America/Los_Angeles';
- $userKey = Account::getUserKey();
- if (!empty($userKey)){
- require_once ('logFile.class.php');
- $logFile = new LogFile();
- $logFileName = '_u';
- $database = self::getConnection();
- $userInfo = array();
- try {
- $query = "SELECT timezone FROM teelaunch_accountUsers WHERE userKey = :userKey LIMIT 1";
- $database->query($query);
- $database->bind(":userKey", $userKey);
- $userInfo = $database->resultsFromDB();
- $userInfo = (!empty($userInfo)) ? current($userInfo) : array();
- } catch (PDOException $e){
- $logFile->writeToLogFile('DB Error on account.php for userKey:' . $userKey . '; message:' . $e->getMessage() . '',
- $logFileName);
- }
- $database = null;
- $localTimeZone = $userInfo['timezone'];
- }
- $date = new DateTime($dateTime . ' +00');
- try {
- $date->setTimezone(new DateTimeZone($localTimeZone));
- } catch(Exception $e){
- if (empty(self::$error)){
- self::$error = 'Please make sure that you have set your timezone on the <a href="/account/">account page</a><br>';
- echo self::$error;
- }
- }
- return $date->format($dateFormat);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement