当前位置:网站首页>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;
}
}
边栏推荐
- MySQL无order by的排序规则因素
- 使用MAME32K进行联机游戏
- Data warehouse model fact table model design
- SSM二手交易网站
- 叮咚,Redis OM对象映射框架来了
- 【信息检索导论】第二章 词项词典与倒排记录表
- MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
- Ding Dong, here comes the redis om object mapping framework
- 【信息检索导论】第七章搜索系统中的评分计算
- Oracle segment advisor, how to deal with row link row migration, reduce high water level
猜你喜欢
[introduction to information retrieval] Chapter 7 scoring calculation in search system
Illustration of etcd access in kubernetes
SSM supermarket order management system
【论文介绍】R-Drop: Regularized Dropout for Neural Networks
sparksql数据倾斜那些事儿
ssm人事管理系统
【Ranking】Pre-trained Language Model based Ranking in Baidu Search
Practice and thinking of offline data warehouse and Bi development
Two table Association of pyspark in idea2020 (field names are the same)
Message queue fnd in Oracle EBS_ msg_ pub、fnd_ Application of message in pl/sql
随机推荐
【信息检索导论】第七章搜索系统中的评分计算
PointNet原理证明与理解
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
Sparksql data skew
【Ranking】Pre-trained Language Model based Ranking in Baidu Search
ssm人事管理系统
一个中年程序员学习中国近代史的小结
Oracle EBS interface development - quick generation of JSON format data
ARP attack
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
MySQL composite index with or without ID
华为机试题-20190417
Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
view的绘制机制(一)
Practice and thinking of offline data warehouse and Bi development
Explanation of suffix of Oracle EBS standard table
Oracle APEX 21.2 installation et déploiement en une seule touche
Oracle RMAN semi automatic recovery script restore phase
《Handwritten Mathematical Expression Recognition with Bidirectionally Trained Transformer》论文翻译
ORACLE EBS 和 APEX 集成登录及原理分析