Example #1
0
 /**
  * Convert a date to a \DateTime instance.
  *
  * @param string|\DateTime|int $value It can be:<ul>
  *    <li>the special value 'now' (default) to return the current date/time</li>
  *    <li>a \DateTime instance</li>
  *    <li>a string parsable by strtotime (the $fromTimezone timezone is used)</li>
  *    <li>a timestamp</li>
  * </ul>
  * @param string $toTimezone The timezone to set. Special values are:<ul>
  *    <li>'system' (default) for the current system timezone</li>
  *    <li>'user' for the user's timezone</li>
  *    <li>'app' for the app's timezone</li>
  *    <li>Other values: one of the PHP supported time zones (see http://us1.php.net/manual/en/timezones.php )</li>
  * </ul>
  * @param string $fromTimezone The original timezone of $value (useful only if $value is a string like '2000-12-31 23:59'); it accepts the same values as $toTimezone.
  *
  * @return \DateTime|null Returns the \DateTime instance (or null if $value couldn't be parsed)
  */
 public function toDateTime($value = 'now', $toTimezone = 'system', $fromTimezone = 'system')
 {
     return Calendar::toDateTime($value, $this->getTimezone($toTimezone), $this->getTimezone($fromTimezone));
 }