当前位置:网站首页>php中时间戳转换为毫秒以及格式化时间
php中时间戳转换为毫秒以及格式化时间
2022-07-02 06:23:00 【夜空の雪風】
前言
有时候需要对时间戳进行操作,比如获取13位毫秒级的时间戳或者对时间戳进行格式化时间。
/** * 转化时间为毫秒时间戳 * @param int|string $time 时间戳|日期 * @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;
}
}
/** * 时间戳转化为日期 * @param int|string $time 时间戳|日期 * @param string $format 格式化方式 * @return string */
function time_format($time, $format = 'Y-m-d')
{
if (is_numeric($time)) {
return date($format, substr($time, 0, 10));
} else {
return $time;
}
}
边栏推荐
- [daily question] - Huawei machine test 01
- Stress test modification solution
- JS delete the last bit of the string
- Virtualenv and pipenv installation
- 20201002 vs 2019 qt5.14 developed program packaging
- 20210306 reprint how to make TextEdit have background pictures
- JS modification element attribute flipping commonly used in selenium's Web Automation
- Render minecraft scenes into real scenes using NVIDIA GPU
- js中map和forEach的用法
- DeprecationWarning: . ix is deprecated. Please use. loc for label based indexing or. iloc for positi
猜你喜欢
ZZQ的博客目录--更新于20210601
微信小程序基础
Linux MySQL 5.6.51 community generic installation tutorial
The table component specifies the concatenation parallel method
Self study table Au
PHP Session原理简析
Brief analysis of PHP session principle
js中map和forEach的用法
Latex 编译报错 I found no \bibstyle & \bibdata & \citation command
AWD learning
随机推荐
解决微信小程序swiper组件bindchange事件抖动问题
Latex 报错 LaTeX Error: The font size command \normalsize is not defined问题解决
JS to determine whether there is a value in the object in the array
js数组的常用的原型方法
Browser scrolling for more implementations
JS delete the last bit of the string
Flex Jiugongge layout
Apt command reports certificate error certificate verification failed: the certificate is not trusted
CAD二次开发 对象
Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss
Kali latest update Guide
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
CTF three count
Latex在VSCODE中编译中文,使用中文路径问题解决
Anti shake and throttling of JS
sqli-labs通关汇总-page3
Stress test modification solution
js中map和forEach的用法
PIP install