当前位置:网站首页>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;
}
}
边栏推荐
- 查询GPU时无进程运行,但是显存却被占用了
- Sqli labs customs clearance summary-page4
- SQLI-LABS通关(less2-less5)
- Win10: add or delete boot items, and add user-defined boot files to boot items
- Uniapp introduces local fonts
- Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence
- In depth study of JVM bottom layer (IV): class file structure
- PHP Session原理简析
- MySQL index
- Nodejs - Express middleware modification header: typeerror [err_invalid_char]: invalid character in header content
猜你喜欢

How to debug wechat built-in browser applications (enterprise number, official account, subscription number)

No process runs when querying GPU, but the video memory is occupied

Uploading attachments using Win32 in Web Automation
![[literature reading and thought notes 13] unprocessing images for learned raw denoising](/img/a5/ed26a90b3edd75a37b2e5164f6b7d2.png)
[literature reading and thought notes 13] unprocessing images for learned raw denoising

SQLI-LABS通关(less1)

Self study table Au

2021-07-05C#/CAD二次开发创建圆弧(4)

Wechat applet Foundation

Sentry搭建和使用

查询GPU时无进程运行,但是显存却被占用了
随机推荐
Common prototype methods of JS array
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)
Recursion (maze problem, Queen 8 problem)
Overload global and member new/delete
SQLI-LABS通关(less18-less20)
JS judge whether the object is empty
No process runs when querying GPU, but the video memory is occupied
js判断对象是否为空
sprintf_ How to use s
SQLI-LABS通关(less1)
js判断数组中对象是否存在某个值
【文献阅读与想法笔记13】 Unprocessing Images for Learned Raw Denoising
查询GPU时无进程运行,但是显存却被占用了
Tool grass welfare post
Improve user experience defensive programming
Latex warning: citation "*****" on page y undefined on input line*
Underlying mechanism mvcc
Record RDS troubleshooting once -- RDS capacity increases dramatically
Log - 7 - record a major error in missing documents (A4 paper)
Queue (linear structure)