当前位置:网站首页>Convert timestamp into milliseconds and format time in PHP
Convert timestamp into milliseconds and format time in PHP
2022-07-02 07:28:00 【Snow wind in the night sky】
Preface
Sometimes you need to operate on the timestamp , Like getting 13 Bit millisecond timestamps or formatted timestamps .
/** * Convert time to millisecond timestamp * @param int|string $time Time stamp | date * @return int */
function get_time($time)
{
if (is_numeric($time)) {
return (int) str_pad($time, 13, "0", STR_PAD_RIGHT);
} else {
return strtotime($time) * 1000;
}
}
/** * Timestamp to date * @param int|string $time Time stamp | date * @param string $format Formatting method * @return string */
function time_format($time, $format = 'Y-m-d')
{
if (is_numeric($time)) {
return date($format, substr($time, 0, 10));
} else {
return $time;
}
}
边栏推荐
- Drawing mechanism of view (I)
- Play online games with mame32k
- JSP intelligent community property management system
- PointNet理解(PointNet实现第4步)
- JSP智能小区物业管理系统
- A slide with two tables will help you quickly understand the target detection
- Transform the tree structure into array in PHP (flatten the tree structure and keep the sorting of upper and lower levels)
- ORACLE EBS 和 APEX 集成登录及原理分析
- 自然辩证辨析题整理
- One field in thinkphp5 corresponds to multiple fuzzy queries
猜你喜欢

DNS attack details
![[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge](/img/2e/e74d7a9efbf9fe617f4d7b46867c0a.png)
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge

使用Matlab实现:Jacobi、Gauss-Seidel迭代

Drawing mechanism of view (I)

Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix

【论文介绍】R-Drop: Regularized Dropout for Neural Networks

spark sql任务性能优化(基础)

【模型蒸馏】TinyBERT: Distilling BERT for Natural Language Understanding

Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix

如何高效开发一款微信小程序
随机推荐
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation
SSM学生成绩信息管理系统
SSM student achievement information management system
Cognitive science popularization of middle-aged people
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
Oracle EBS ADI development steps
Transform the tree structure into array in PHP (flatten the tree structure and keep the sorting of upper and lower levels)
华为机试题-20190417
Typeerror in allenlp: object of type tensor is not JSON serializable error
架构设计三原则
Interpretation of ernie1.0 and ernie2.0 papers
使用MAME32K进行联机游戏
Oracle段顾问、怎么处理行链接行迁移、降低高水位
[introduction to information retrieval] Chapter 6 term weight and vector space model
【Torch】解决tensor参数有梯度,weight不更新的若干思路
One field in thinkphp5 corresponds to multiple fuzzy queries
【Torch】最简洁logging使用指南
常见的机器学习相关评价指标
Oracle RMAN automatic recovery script (migration of production data to test)
ssm超市订单管理系统