当前位置:网站首页>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;
}
}
边栏推荐
- 软件开发模式之敏捷开发(scrum)
- Spark SQL task performance optimization (basic)
- Only the background of famous universities and factories can programmers have a way out? Netizen: two, big factory background is OK
- 生成模型与判别模型的区别与理解
- Agile development of software development pattern (scrum)
- 中年人的认知科普
- Oracle apex Ajax process + dy verification
- ssm+mysql实现进销存系统
- 优化方法:常用数学符号的含义
- Three principles of architecture design
猜你喜欢

MapReduce concepts and cases (Shang Silicon Valley Learning Notes)

@Transitional step pit
![[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

【Ranking】Pre-trained Language Model based Ranking in Baidu Search

【信息检索导论】第三章 容错式检索

架构设计三原则

Play online games with mame32k

ssm超市订单管理系统

Practice and thinking of offline data warehouse and Bi development
![[model distillation] tinybert: distilling Bert for natural language understanding](/img/c1/e1c1a3cf039c4df1b59ef4b4afbcb2.png)
[model distillation] tinybert: distilling Bert for natural language understanding
随机推荐
CONDA creates, replicates, and shares virtual environments
Determine whether the version number is continuous in PHP
Cognitive science popularization of middle-aged people
使用MAME32K进行联机游戏
SSM student achievement information management system
@Transational踩坑
【调参Tricks】WhiteningBERT: An Easy Unsupervised Sentence Embedding Approach
自然辩证辨析题整理
Get the uppercase initials of Chinese Pinyin in PHP
RMAN incremental recovery example (1) - without unbacked archive logs
ssm垃圾分类管理系统
点云数据理解(PointNet实现第3步)
Proteus -- RS-232 dual computer communication
Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
如何高效开发一款微信小程序
Oracle segment advisor, how to deal with row link row migration, reduce high water level
[introduction to information retrieval] Chapter 3 fault tolerant retrieval
使用Matlab实现:Jacobi、Gauss-Seidel迭代
Pyspark build temporary report error
[torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated