当前位置:网站首页>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;
}
}
边栏推荐
- Vscode installation, latex environment, parameter configuration, common problem solving
- DeprecationWarning: . ix is deprecated. Please use. loc for label based indexing or. iloc for positi
- 默认google浏览器打不开链接(点击超链接没有反应)
- In depth study of JVM bottom layer (II): hotspot virtual machine object
- js把一个数组分割成每三个一组
- Self study table Au
- Record RDS troubleshooting once -- RDS capacity increases dramatically
- sqli-labs通关汇总-page4
- The default Google browser cannot open the link (clicking the hyperlink does not respond)
- JS judge whether the object is empty
猜你喜欢

Sqli-labs customs clearance (less6-less14)

Flex Jiugongge layout

解决微信小程序swiper组件bindchange事件抖动问题

Usage of map and foreach in JS

默认google浏览器打不开链接(点击超链接没有反应)

uniapp引入本地字体

Win电脑截图黑屏解决办法

Sentry construction and use

Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)

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)
随机推荐
Self study table Au
2020-9-23 use of QT timer qtimer class.
pm2简单使用和守护进程
Tool grass welfare post
【文献阅读与想法笔记13】 Unprocessing Images for Learned Raw Denoising
Win电脑截图黑屏解决办法
CTF web practice competition
Flask migrate cannot detect db String() equal length change
Promise中有resolve和无resolve的代码执行顺序
PgSQL learning notes
Nodejs - Express middleware modification header: typeerror [err_invalid_char]: invalid character in header content
Virtualenv and pipenv installation
Implement strstr() II
Code execution sequence with and without resolve in promise
[leetcode question brushing day 35] 1060 Missing element in ordered array, 1901 Find the peak element, 1380 Lucky number in matrix
Kali latest update Guide
Thread hierarchy in CUDA
Fe - eggjs combined with typeorm cannot connect to the database
The default Google browser cannot open the link (clicking the hyperlink does not respond)
Sqli labs customs clearance summary-page4