当前位置:网站首页>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;
}
}
边栏推荐
- 华为机试题-20190417
- 一个中年程序员学习中国近代史的小结
- A summary of a middle-aged programmer's study of modern Chinese history
- CONDA creates, replicates, and shares virtual environments
- Oracle apex 21.2 installation and one click deployment
- JSP智能小区物业管理系统
- ERNIE1.0 与 ERNIE2.0 论文解读
- [Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
- Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
- Oracle general ledger balance table GL for foreign currency bookkeeping_ Balance change (Part 1)
猜你喜欢
SSM supermarket order management system
常见CNN网络创新点
How to efficiently develop a wechat applet
Using MATLAB to realize: Jacobi, Gauss Seidel iteration
TCP attack
MySQL has no collation factor of order by
Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
Sparksql data skew
[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
DNS attack details
随机推荐
使用MAME32K进行联机游戏
Point cloud data understanding (step 3 of pointnet Implementation)
Spark SQL task performance optimization (basic)
Feeling after reading "agile and tidy way: return to origin"
Oracle RMAN automatic recovery script (migration of production data to test)
Error in running test pyspark in idea2020
【信息检索导论】第二章 词项词典与倒排记录表
Oracle APEX 21.2 installation et déploiement en une seule touche
使用Matlab实现:弦截法、二分法、CG法,求零点、解方程
一份Slide两张表格带你快速了解目标检测
oracle apex ajax process + dy 校验
CSRF attack
Implementation of purchase, sales and inventory system with ssm+mysql
【信息检索导论】第一章 布尔检索
生成模型与判别模型的区别与理解
Using MATLAB to realize: power method, inverse power method (origin displacement)
MySQL组合索引加不加ID
How to efficiently develop a wechat applet
A summary of a middle-aged programmer's study of modern Chinese history
常见的机器学习相关评价指标