当前位置:网站首页>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;
}
}
边栏推荐
- MapReduce concepts and cases (Shang Silicon Valley Learning Notes)
- Using MATLAB to realize: Jacobi, Gauss Seidel iteration
- Delete the contents under the specified folder in PHP
- PHP uses the method of collecting to insert a value into the specified position in the array
- view的绘制机制(三)
- Jordan decomposition example of matrix
- 一个中年程序员学习中国近代史的小结
- @Transational踩坑
- Oracle EBS DataGuard setup
- 中年人的认知科普
猜你喜欢

【调参Tricks】WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach
![[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table](/img/3f/09f040baf11ccab82f0fc7cf1e1d20.png)
[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table

生成模型与判别模型的区别与理解

读《敏捷整洁之道:回归本源》后感

@Transational踩坑
![[introduction to information retrieval] Chapter 3 fault tolerant retrieval](/img/75/ac2fdcd256f5c2336ca53c7a2744b8.png)
[introduction to information retrieval] Chapter 3 fault tolerant retrieval

Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK

Principle analysis of spark

Changes in foreign currency bookkeeping and revaluation general ledger balance table (Part 2)

腾讯机试题
随机推荐
解决万恶的open failed: ENOENT (No such file or directory)/(Operation not permitted)
[introduction to information retrieval] Chapter 1 Boolean retrieval
ARP attack
離線數倉和bi開發的實踐和思考
ORACLE EBS DATAGUARD 搭建
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
常见CNN网络创新点
Oracle EBS ADI development steps
CRP实施方法论
Oracle EBs and apex integrated login and principle analysis
SSM实验室设备管理
Using MATLAB to realize: power method, inverse power method (origin displacement)
Transform the tree structure into array in PHP (flatten the tree structure and keep the sorting of upper and lower levels)
Using MATLAB to realize: Jacobi, Gauss Seidel iteration
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation
DNS attack details
【信息检索导论】第二章 词项词典与倒排记录表
【Torch】解决tensor参数有梯度,weight不更新的若干思路
自然辩证辨析题整理
MySQL组合索引加不加ID