php时间轴函数 ,刚、1分钟前、1小时前、一天前
php时间轴函数 ,刚刚、1分钟前、1小时前、一天前
php常见时间处理函数:
time():返回当前的 Unix 时间戳?。
date():格式化一个本地时间/日期。
getdate():取得日期/时间信息。
mktime():正常日期转时间戳。mktime(0, 0, 0, 9, 18, 2011)
如下是一个时间轴处理函数
/** * 时间格式化 */ static function formatDate($time){ $rtime = date ( "m-d H:i", $time ); $htime = date ( "H:i", $time ); $time = time () - $time; if ($time < 60) { $str = '刚刚'; } elseif ($time < 60 * 60) { $min = floor ( $time / 60 ); $str = $min . '分钟前'; } elseif ($time < 60 * 60 * 24) { $h = floor ( $time / (60 * 60) ); $str = $h . '小时前 ' . $htime; } elseif ($time < 60 * 60 * 24 * 3) { $d = floor ( $time / (60 * 60 * 24) ); if ($d == 1) $str = '昨天 ' . $rtime; else $str = '前天 ' . $rtime; } else { $str = $rtime; } return $str; }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Today we are mainly going to take a look at the time application method of golang time package. The general rule between the two is that "wall time" is used to tell time, and "monotonic clock" is used to measure time; there are other clock processing methods.

1. Overview As part of this article, let us start with some problems with the existing Date and CalendarAPI and explore how the new Java8Date and TimeAPI solve these problems. We will also take a look at the core classes in the Java8 time class library, such as LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Period, Duration and their APIs. 2. The problem of thread safety of the old time API (before Java 8)-Date and Calendar classes are not thread-safe, making it difficult for developers to debug concurrency problems of these APIs and need to write additional code to deal with them.

Pythontime module time acquisition and conversion Python's Time library can perform time-related processing, such as accessing the current date and time, outputting time in different formats, and waiting for a specified time. 1. Get the time 1.1. Timestamp importtimetimestamp=time.time()#1682737552.5009851 Greenwich Mean Time (GMT) The total number of seconds from 00:00:00 on January 1, 1970 to the present 1.2. Structured time importtimestruct_time= time.localtime()#time.struct_time(tm_year=2

1The basic unit of Unicode computer storage is the byte, which is composed of 8 bits. Since English only consists of 26 letters plus a number of symbols, English characters can be stored directly in bytes. But other languages (such as Chinese, Japanese, Korean, etc.) have to use multiple bytes for encoding due to the large number of characters. With the spread of computer technology, non-Latin character encoding technology continues to develop, but there are still two major limitations: no multi-language support: the encoding scheme of one language cannot be used in another language and there is no unified standard: for example There are many encoding standards in Chinese such as GBK, GB2312, GB18030, etc. Since the encoding methods are not unified, developers need to convert back and forth between different encodings, and many errors will inevitably occur.

1. Two ways to represent time in Python: timestamp: offset in seconds relative to 1970.1.100:00:00, unique time tuple struct_time: a total of 9 elements>tm_year: year 1-12> tm_mon: month 1-12>tm_mday: day 1-31>tm_hour: hour 0-23>tm_min: minute 0-59>tm_sec: second 0-59>tm_wday: week 0-6 (0 means Sunday)>tm_day: Day of the year 1-366>tm_isdst: whether it is daylight saving, the default is -1.ti

What are the similarities and differences between __str__ and __repr__? We all know the representation of strings. Python's built-in function repr() can express objects in the form of strings to facilitate our identification. This is the "string representation". repr() obtains the string representation of an object through the special method __repr__. If __repr__ is not implemented, when we print an instance of a vector to the console, the resulting string may be. >>>classExample:pass>>>print(str(Example()))>>>

Golang is a very popular programming language. Its easy-to-learn, efficient and fast features attract more and more developers. But during use, you will inevitably encounter some problems and errors. For example, when using the After method in the time package, you may encounter an error of undefined: time.After. This article will introduce how to solve this error. Understand the cause of the error In Golang, if we use an unexported function name or incorrect

Usage and precautions of the elseif keyword in PHP In PHP programming, elseif is a very useful keyword for adding more branches to conditional judgments. This article will introduce the usage and precautions of the elseif keyword in detail. Syntax and usage: The elseif statement is used to add a new branch to the conditional judgment, which makes a judgment when the condition in the if statement is not met. Its basic syntax is as follows: if(condition1){//Execute code block
