/** * @param string|Moment $fromMoment * @param null $timezoneString * * @return MomentFromVo */ public function from($fromMoment = 'now', $timezoneString = null) { // create moment first if ($this->isMoment($fromMoment) === false) { // use custom timezone or fallback the current moment $useTimezoneString = $timezoneString !== null ? $timezoneString : $this->getTimezoneString(); $fromMoment = new Moment($fromMoment, $useTimezoneString); } // calc difference between dates $dateDiff = parent::diff($fromMoment); $momentFromVo = new MomentFromVo($fromMoment); return $momentFromVo->setDirection($dateDiff->format('%R'))->setSeconds($this->fromToSeconds($dateDiff))->setMinutes($this->fromToMinutes($dateDiff))->setHours($this->fromToHours($dateDiff))->setDays($this->fromToDays($dateDiff))->setWeeks($this->fromToWeeks($dateDiff)); }
/** * @param string $dateTime * @param null $timezoneString * * @return MomentFromVo */ public function from($dateTime = 'now', $timezoneString = null) { // use custom timezone or fallback the current moment $useTimezoneString = $timezoneString !== null ? $timezoneString : $this->getTimezoneString(); $fromMoment = new Moment($dateTime, $useTimezoneString); $dateDiff = parent::diff($fromMoment); $momentFromVo = new MomentFromVo(); return $momentFromVo->setMoment($fromMoment)->setDirection($dateDiff->format('%R'))->setSeconds($this->fromToSeconds($dateDiff))->setMinutes($this->fromToMinutes($dateDiff))->setHours($this->fromToHours($dateDiff))->setDays($this->fromToDays($dateDiff))->setWeeks($this->fromToWeeks($dateDiff)); }