首页内核与基础Helper-时间与格式化族
Helper-时间与格式化族
时间起点、大小格式化、脱敏、价格转换等数据处理方法
本页内容
  1. 时间起点
  2. 格式化与脱敏

时间起点

方法签名说明
timeTodaystarttimeTodaystart($offset=0)今天零点时间戳,$offset 为天数偏移
timeWeekstarttimeWeekstart($offset=0)周起点时间戳
timeMonthstarttimeMonthstart($offset=0)本月 1 日零点,$offset 为月偏移
timeYearstarttimeYearstart($offset=0)本年 1 月 1 日零点,$offset 为年偏移
timelentimelen($code)秒数 → "X天/时/分/秒" 可读时长
getNumbergetNumber($priex="")前缀 + 年月日时分秒 + 3 位随机数编号

格式化与脱敏

方法签名说明
sizeByte / int2filesize($code) / ($int)字节数转可读大小(int2filesize 保留 2 位小数)
priceprice($code)分 → 元格式化(FilterOutputModel::filterPrice)
price2numberprice2number($code)元 → 分(×100 取整)
number2pricenumber2price($code)数字转价格(等价 price)
phonephone($phone)手机号脱敏
idcodeidcode($code)身份证脱敏
code2strcode2str($code)代码片段转显示字符串(< > 转实体)
symbolsToonesymbolsToone($str,$replace=",")标点符号统一替换为指定符号并合并连续
strTobytestrTobyte($str)"10M"/"10K" → 字节数(Secret 类)
典型用法
// 今日订单
$start = \Kuoqi\Helper::timeTodaystart();
$rows  = M("order")->where(array("create_time" => array(">=", $start)))->select();

// 金额显示(分 → 元)
echo \Kuoqi\Helper::price(1990);            // 19.90

// 订单号生成
$no = \Kuoqi\Helper::getNumber("KQ");       // KQ20260831102033xxx
KuoqiPHP v1.05 · 离线静态文档 · 界面基于 KuoqiUI · 返回首页