public function getSignInDate() { $date_string = get_option(self::SIGN_IN_DATE_KEY); if (!$date_string) { return new DateTime(); } $stored_time = PushMonkeyDateTime::createFromFormat(self::DATE_FORMAT, $date_string); return $stored_time; }
/** * Get a value from cache, if available. * @param string $key * @return mixed; returns false if cache is expired or nothing has been cached. Otherwise, * it returns the cached value. */ public function get($key) { $store = get_option($key, false); if (!$store) { return false; } $now = new PushMonkeyDateTime(); $stored_time = PushMonkeyDateTime::createFromFormat(self::DATE_FORMAT, $store['expiration']); $interval = $stored_time->getTimestamp() - $now->getTimestamp(); if ($interval < 0) { return false; } return $store['value']; }