Changeset 740 for trunk/lib/App.inc.php


Ignore:
Timestamp:
Nov 30, 2020 2:27:06 AM (3 years ago)
Author:
anonymous
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/App.inc.php

    r739 r740  
    18791879        }
    18801880
    1881         // Create a DateTime object and conver the timezone from server to user.
    1882         $dt = $this->convertTZ($datetime, $this->getParam('php_timezone'), $this->getParam('user_timezone'));
     1881        try {
     1882            // Create a DateTime object and conver the timezone from server to user.
     1883            $dt = $this->convertTZ($datetime, $this->getParam('php_timezone'), $this->getParam('user_timezone'));
     1884        } catch (Exception $e) {
     1885            $this->logMsg(sprintf('DateTime failed to parse string in %s: %s', __METHOD__, $datetime), LOG_NOTICE, __FILE__, __LINE__);
     1886            return '';
     1887        }
    18831888
    18841889        // By default, we try to use a localized date format. Set lc_date_format to null to use regular date_format instead.
     
    19061911    function dateToServerTZ($datetime, $format='Y-m-d H:i:s')
    19071912    {
    1908         return $this->convertTZ($datetime, $this->getParam('user_timezone'), $this->getParam('php_timezone'))->format($format);
     1913        try {
     1914            // Create a DateTime object and conver the timezone from server to user.
     1915            $dt = $this->convertTZ($datetime, $this->getParam('user_timezone'), $this->getParam('php_timezone'));
     1916        } catch (Exception $e) {
     1917            $this->logMsg(sprintf('DateTime failed to parse string in %s: %s', __METHOD__, $datetime), LOG_NOTICE, __FILE__, __LINE__);
     1918            return '';
     1919        }
     1920
     1921        return $dt->format($format);
    19091922    }
    19101923
Note: See TracChangeset for help on using the changeset viewer.