当前位置:网站首页>How long ago did PHP get
How long ago did PHP get
2022-06-26 12:23:00 【ζ He Yiyi】
// How long ago
function formatDate($time)
{
if (!$time)
return false;
$fdate = '';
$d = time() - intval($time);
$ld = $time - mktime(0, 0, 0, 0, 0, date('Y')); // Derived year
$md = $time - mktime(0, 0, 0, date('m'), 0, date('Y')); // Have a moon
$byd = $time - mktime(0, 0, 0, date('m'), date('d') - 2, date('Y')); // The day before yesterday
$yd = $time - mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); // yesterday
$dd = $time - mktime(0, 0, 0, date('m'), date('d'), date('Y')); // today
$td = $time - mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')); // Tomorrow,
$atd = $time - mktime(0, 0, 0, date('m'), date('d') + 2, date('Y')); // The day after tomorrow
if ($d == 0) {
$fdate = ' just ';
} else {
switch ($d) {
case $d < $atd:
$fdate = date('Y year m month d Japan ', $time);
break;
case $d < $td:
$fdate = ' The day after tomorrow ' . date('H:i', $time);
break;
case $d < 0:
$fdate = ' Tomorrow, ' . date('H:i', $time);
break;
case $d < 60:
$fdate = $d . ' Seconds ago ';
break;
case $d < 3600:
$fdate = floor($d / 60) . ' Minutes ago ';
break;
case $d < $dd:
$fdate = floor($d / 3600) . ' Hours before ';
break;
case $d < $yd:
$fdate = ' yesterday ' . date('H:i', $time);
break;
case $d < $byd:
$fdate = ' The day before yesterday ' . date('H:i', $time);
break;
case $d < $md:
$fdate = date('m month d Japan H:i', $time);
break;
case $d < $ld:
$fdate = date('m month d Japan ', $time);
break;
default:
$fdate = date('Y year m month d Japan ', $time);
break;
}
}
return $fdate;
}
边栏推荐
- 我想知道同花顺是炒股的么?在线开户安全么?
- Question B of 2016 Sichuan Ti Cup Electronic Design Competition
- HUST网络攻防实践|6_物联网设备固件安全实验|实验二 基于 MPU 的物联网设备攻击缓解技术
- Please advise tonghuashun which securities firm to choose for opening an account? Is it safe to open a mobile account?
- SQL injection in Pikachu shooting range
- Analysis report on dynamic research and investment planning suggestions of China's laser medical market in 2022
- webgame开发中的文件解密
- HUST網絡攻防實踐|6_物聯網設備固件安全實驗|實驗二 基於 MPU 的物聯網設備攻擊緩解技術
- 18: Chapter 3: development of pass service: 1: SMS login & registration process, introduction; (SMS verification code is used here)
- Member system + enterprise wechat + applet to help the efficient transformation of private domain
猜你喜欢

New routing file in laravel framework

Mysql8 master-slave replication

MOS管基本原理,单片机重要知识点

HUST网络攻防实践|6_物联网设备固件安全实验|实验二 基于 MPU 的物联网设备攻击缓解技术

1、 MySQL introduction

Scala problem solving the problem of slow SBT Download

Basic principle of MOS tube and important knowledge points of single chip microcomputer
The loss of female scientists

AD - 将修改后的 PCB 封装更新到当前 PCB 中

国际美妆业巨头押注中国
随机推荐
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
Oracle锁表查询和解锁方法
18: Chapter 3: development of pass service: 1: SMS login & registration process, introduction; (SMS verification code is used here)
这两天搭建环境遇到的几个问题
How to calculate flops and params in deep learning
Scala-day02- variables and data types
Lintcode 130 · stacking
Hello! Forward proxy!
Scala-day06- pattern matching - Generic
Spark-day03-core programming RDD operator
Introduction to Dolby panoramic sound
Using the methods in the repository to solve practical problems
1、 MySQL introduction
How do consumer goods enterprises formulate membership interests?
19: Chapter 3: develop pass service: 2: get through Alibaba cloud SMS service in the program; (it only connects with Alibaba cloud SMS server, and does not involve specific business development)
Comparison of latest mobile phone processors in 2020 (with mobile phone CPU ladder diagram)
Polarismesh series articles - concept series (I)
On the use of protostaff [easy to understand]
Is it safe to open a securities account
International beauty industry giants bet on China