首页›内核与基础›Helper-时间与格式化族
Helper-时间与格式化族
时间起点、大小格式化、脱敏、价格转换等数据处理方法
本页内容
- 时间起点
- 格式化与脱敏
时间起点
| 方法 | 签名 | 说明 |
|---|---|---|
timeTodaystart | timeTodaystart($offset=0) | 今天零点时间戳,$offset 为天数偏移 |
timeWeekstart | timeWeekstart($offset=0) | 周起点时间戳 |
timeMonthstart | timeMonthstart($offset=0) | 本月 1 日零点,$offset 为月偏移 |
timeYearstart | timeYearstart($offset=0) | 本年 1 月 1 日零点,$offset 为年偏移 |
timelen | timelen($code) | 秒数 → "X天/时/分/秒" 可读时长 |
getNumber | getNumber($priex="") | 前缀 + 年月日时分秒 + 3 位随机数编号 |
格式化与脱敏
| 方法 | 签名 | 说明 |
|---|---|---|
sizeByte / int2filesize | ($code) / ($int) | 字节数转可读大小(int2filesize 保留 2 位小数) |
price | price($code) | 分 → 元格式化(FilterOutputModel::filterPrice) |
price2number | price2number($code) | 元 → 分(×100 取整) |
number2price | number2price($code) | 数字转价格(等价 price) |
phone | phone($phone) | 手机号脱敏 |
idcode | idcode($code) | 身份证脱敏 |
code2str | code2str($code) | 代码片段转显示字符串(< > 转实体) |
symbolsToone | symbolsToone($str,$replace=",") | 标点符号统一替换为指定符号并合并连续 |
strTobyte | strTobyte($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 ·
返回首页