消息历史记录下载地址获取 方法消息历史记录下载地址获取方法。获取 APP 内指定某天某小时内的所有会话消息记录的下载地址。（目前支持二人会话、讨论组、群组、聊天室、客服、系统通知消息历史记录下载）

@param  date:指定北京时间某天某小时，格式为2014010101,表示：2014年1月1日凌晨1点。（必传）

@return $json
335935
public function getHistory($date) {
    	try{
			if (empty($date))
				throw new Exception('Paramer "date" is required');


    		$params = array (
    		'date' => $date
    		);

    		$ret = $this->SendRequest->curl('/message/history.json',$params,'urlencoded','im','POST');
    		if(empty($ret))
    			throw new Exception('bad request');
    		return $ret;

    	}catch (Exception $e) {
    		print_r($e->getMessage());
    	}
   }
1166834
public static function dataPascoa($date)
    {
        $date = static::prepareDate($date);

        $ano = @$date->year;
        if (static::$pascoa) {
            if ($ano == static::$pascoa->getYear()) {
                return static::$pascoa;
            }
        }
        $c = floor($ano / 100);
        $n = $ano - (19 * floor($ano / 19));
        $k = floor(($c - 17) / 25);
        $i = $c - floor($c / 4) - floor(($c - $k) / 3) + (19 * $n) + 15;
        $i = $i - (30 * floor($i / 30));
        $i = $i - (floor($i / 28) * (1 - floor($i / 28)) * floor(29 / ($i + 1)) * floor((21 - $n) / 11));
        $j = $ano + floor($ano / 4) + $i + 2 -$c + floor($c / 4);
        $j = $j - (7 * floor($j / 7));
        $L = $i - $j;
        $mes = 3 + floor(($L + 40) / 44);
        $dia = $L + 28 - (31 * floor($mes / 4));
        static::$pascoa = DateTimeBr::createFromDate($ano, $mes, $dia);

        return static::$pascoa;
    }
792092
function formatDate( date ) {

	var dateString = '';

	date = new Date( date );

	dateString = date.getMonth() + 1;
	dateString += '/';
	dateString += date.getDate();
	dateString += '/';
	dateString += date.getFullYear();

	return dateString;
}
39520
public String getDateTime(Date date) {

        return CmsDateUtil.getDateTime(date, DateFormat.SHORT, m_locale);
    }
519944
function getDisplayDate(date) {
        var monthStrings = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

        date = new Date(date);

        var hours = date.getHours();
        if (hours < 10) {
            hours = "0" + hours.toString();
        }
        var mins = date.getMinutes();
        if (mins < 10) {
            mins = "0" + mins.toString();
        }

        return monthStrings[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear() +
            " - " + hours + ":" + mins + " " + (date.getUTCHours() < 12 ? "AM" : "PM");
    }
836486
public function evaluateExclusions($date = null)
    {
        if (!$date) {
            $date = clone $this->now;
        }
        // Check dates of exclusion (if there are any).
        $jsonHelper       = new JSONHelper();
        $exclusionsString = $this->contactClient->getScheduleExclusions();
        $exclusions       = $jsonHelper->decodeArray($exclusionsString, 'ScheduleExclusions');
        if ($exclusions) {
            // Fastest way to compare dates is by string.
            $todaysDateString = $date->format('Y-m-d');
            foreach ($exclusions as $exclusion) {
                if (!empty($exclusion->value)) {
                    $dateString   = trim(str_ireplace('yyyy-', '', $exclusion->value));
                    $segments     = explode('-', $dateString);
                    $segmentCount = count($segments);
                    if (3 == $segmentCount) {
                        $year  = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            4,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format(
                            'Y'
                        );
                        $month = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[2]) ? str_pad(
                            $segments[2],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } elseif (2 == $segmentCount) {
                        $year  = $date->format('Y');
                        $month = !empty($segments[0]) ? str_pad(
                            $segments[0],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('m');
                        $day   = !empty($segments[1]) ? str_pad(
                            $segments[1],
                            2,
                            '0',
                            STR_PAD_LEFT
                        ) : $date->format('d');
                    } else {
                        continue;
                    }
                    $dateString = $year.'-'.$month.'-'.$day;
                    if ($dateString == $todaysDateString) {
                        throw new ContactClientException(
                            'This contact client does not allow contacts on the date '.$dateString.'.',
                            0,
                            null,
                            Stat::TYPE_SCHEDULE,
                            false
                        );
                    }
                }
            }
        }

        return $this;
    }
907739
public String dateToString(Date date)
    {
        if (date == null)
            return "";
        try {
            return DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(date);
        } catch (Exception ex) {
        }
        return "";
    }
946131
public static function shortDate($date)
    {
        if (self::isDate($date)) {
            $str = self::dateTimeToTimeStamp($date);
            $string = date("d.m.Y", $str);
            return $string;
        } else {
            return null;
        }
    }
1208176
public static function dateTimePHP2Sql($date)
	{
		// 31/01/2016 20:20:00 --> 2016-01-31 00:00
		if ($date == null) {
			return DaoOne::$dateEpoch;
		}
		if ($date->format("u")!='000000') {
			return $date->format('Y-m-d H:i:s.u');
		} else {
			return $date->format('Y-m-d H:i:s');
		}

	}
241906
public function set_date($date = null)
    {
        if (is_null($date)) {
            return $this->set_timestamp(time());
        }
        elseif (is_numeric($date)) {
            return $this->set_timestamp($date);
        }
        elseif (is_a($date, self::class)) {
            /** @var Datetime $date */
            return $this->set_date($date->format());
        }
        elseif (preg_match(self::REGEX_SQL, $date, $dateSplitted)) {
            if (\checkdate($dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y'])) {
                $h = (array_key_exists('h', $dateSplitted) && is_numeric($dateSplitted['h'])) ? $dateSplitted['h'] : 0;
                $m = (array_key_exists('m', $dateSplitted) && is_numeric($dateSplitted['m'])) ? $dateSplitted['m'] : 0;
                $s = (array_key_exists('s', $dateSplitted) && is_numeric($dateSplitted['s'])) ? $dateSplitted['s'] : 0;
    
                $mkt = mktime($h, $m, $s, $dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y']);
                $this->set_date($mkt);
                return $this;
            }
            else {
                return false;
            }
        }
        elseif (preg_match(self::REGEX_STR, $date, $dateSplitted)) {
            if (\checkdate($dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y'])) {
                $h = (array_key_exists('h', $dateSplitted) && is_numeric($dateSplitted['h'])) ? $dateSplitted['h'] : 0;
                $m = (array_key_exists('m', $dateSplitted) && is_numeric($dateSplitted['m'])) ? $dateSplitted['m'] : 0;
                $s = (array_key_exists('s', $dateSplitted) && is_numeric($dateSplitted['s'])) ? $dateSplitted['s'] : 0;
                
                $mkt = mktime($h, $m, $s, $dateSplitted['M'], $dateSplitted['D'], $dateSplitted['Y']);
                $this->set_date($mkt);
                
                return $this;
            }
            else {
                return false;
            }
        }
        elseif (preg_match(self::REGEX_SEM, $date, $dateSplitted)) {
            $baseDt = new \DateTime();
            $baseDt->setISOdate($dateSplitted['Y'], $dateSplitted['S']);
            return $this->set_date($baseDt->getTimestamp());
        }
        
        return false;
    }
935474
public static java.util.Date toJavaUtilDate(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    // Calender.MONTH starts from 0 while G C date starts from 1
    cal.set(date.year, date.month - 1, date.dayOfMonth);
    return cal.getTime();
  }
194030
public static String formatDate(Date date) {
        return org.apache.http.client.utils.DateUtils.formatDate(date);
    }
871664
static public function humanTime($date)
    {
        $diffTime = time() - strtotime($date);

        if ($diffTime < 60) {
            return "刚刚";
        }

        if ($diffTime < 3600) {
            return (intdiv($diffTime, 60) ?: 1)."分钟前";
        }

        if ($diffTime < 86400) {
            return (intdiv($diffTime, 3600) ?: 1)."小时前";
        }

        if ($diffTime < 2592000) {
            return (intdiv($diffTime, 86400) ?: 1)."天前";
        }

        if ($diffTime < 15552000) {
            return (intdiv($diffTime, 2592000) ?: 1)."个月前";
        }

        if ($diffTime < 31536000) {
            return "半年前";
        }

        return (intdiv($diffTime, 31536000) ?: 1)."年前";
    }
798392
public String getDate(Date date) {

        return CmsDateTimeUtil.getDate(date, CmsDateTimeUtil.Format.SHORT);
    }
419155
protected static function strBrToUs($date)
    {
        if (is_string($date)) {
            $expreg = '/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})(T| ){0,1}(([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])){0,1}$/';
            if (preg_match($expreg, $date, $datebit)) {
                @list($tudo, $dia, $mes, $ano, $tz, $time, $hora, $min, $seg) = $datebit;

                return "$ano-$mes-$dia" . ($hora | $min | $seg ? "$hora:$min:$seg" : "");
            }
        }
        return null;
    }
343664
public String getDate(Date date) {

        return CmsDateUtil.getDate(date, DateFormat.SHORT, m_locale);
    }
691915
private JSONArray datesToJson(Collection<Date> individualDates) {

        if (null != individualDates) {
            JSONArray result = new JSONArray();
            for (Date d : individualDates) {
                result.put(dateToJson(d));
            }
            return result;
        }
        return null;
    }