protected function newDate($desiredTZ, $date = false)
    {
        if ($date === false) {
            $date = 'now';
        }

        try {
            $newDate = new Date(is_numeric('' . $date) ? '@' . $date : $date, $desiredTZ);

            // if the string TZ was not the desired TZ, we must convert it
            //$temp = new DateTime(is_numeric(''.$date)?'@'.$date:$date);
            //if(intVal($temp->format('Z')) != $desiredTZ->getOffset(new DateTime()))
            $newDate->setTimezone($desiredTZ);
        } catch (Exception $e) {
            throw new DateException($e);
        }

        unset($date);
        unset($desiredTZ);

        return $newDate;
    }
protected function newDate($desiredTZ, $date = false)
    {
        if ($date === false) {
            $date = 'now';
        }

        try {
            $newDate = new Date(is_numeric('' . $date) ? '@' . $date : $date, $desiredTZ);

            // if the string TZ was not the desired TZ, we must convert it
            //$temp = new DateTime(is_numeric(''.$date)?'@'.$date:$date);
            //if(intVal($temp->format('Z')) != $desiredTZ->getOffset(new DateTime()))
            $newDate->setTimezone($desiredTZ);
        } catch (Exception $e) {
            throw new DateException($e);
        }

        unset($date);
        unset($desiredTZ);

        return $newDate;
    }
protected function newDate ( $ desiredTZ , $ date = false ) { if ( $ date === false ) { $ date = 'now' ; } try { $ newDate = new Date ( is_numeric ( '' . $ date ) ? '@' . $ date : $ date , $ desiredTZ ) ; // if the string TZ was not the desired TZ, we must convert it //$temp = new DateTime(is_numeric(''.$date)?'@'.$date:$date); //if(intVal($temp->format('Z')) != $desiredTZ->getOffset(new DateTime())) $ newDate -> setTimezone ( $ desiredTZ ) ; } catch ( Exception $ e ) { throw new DateException ( $ e ) ; } unset ( $ date ) ; unset ( $ desiredTZ ) ; return $ newDate ; }
Creates a new date in the desired timezone

@param string $desiredTZ The desired timezone in which to return the date
@param mixed $date       An initialization string used to define the date.

@return Date

@throws \DateException
Creates a new date in the desired timezone