当前位置:网站首页>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;
}
}
边栏推荐
- PointNet理解(PointNet实现第4步)
- Huawei machine test questions
- SSM second hand trading website
- 如何高效开发一款微信小程序
- 【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
- 【论文介绍】R-Drop: Regularized Dropout for Neural Networks
- 常见的机器学习相关评价指标
- [paper introduction] r-drop: regulated dropout for neural networks
- Delete the contents under the specified folder in PHP
- Oracle EBS ADI development steps
猜你喜欢
A slide with two tables will help you quickly understand the target detection
[introduction to information retrieval] Chapter 7 scoring calculation in search system
ORACLE EBS ADI 开发步骤
[introduction to information retrieval] Chapter 1 Boolean retrieval
Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
Alpha Beta Pruning in Adversarial Search
Sparksql data skew
【信息检索导论】第三章 容错式检索
【信息检索导论】第七章搜索系统中的评分计算
Illustration of etcd access in kubernetes
随机推荐
Delete the contents under the specified folder in PHP
【调参Tricks】WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach
SSM二手交易网站
【信息检索导论】第一章 布尔检索
Network security -- intrusion detection of emergency response
Oracle apex Ajax process + dy verification
Ding Dong, here comes the redis om object mapping framework
view的绘制机制(二)
CONDA creates, replicates, and shares virtual environments
Oracle段顾问、怎么处理行链接行迁移、降低高水位
Calculate the difference in days, months, and years between two dates in PHP
自然辩证辨析题整理
Three principles of architecture design
SSM second hand trading website
parser.parse_args 布尔值类型将False解析为True
矩阵的Jordan分解实例
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
Transform the tree structure into array in PHP (flatten the tree structure and keep the sorting of upper and lower levels)
华为机试题-20190417