Table of Contents
A summary of all PHP timestamp formats (getting time, timestamp), php
Home Backend Development PHP Tutorial Summary of all PHP timestamp formats (getting time, timestamp), php_PHP tutorial

Summary of all PHP timestamp formats (getting time, timestamp), php_PHP tutorial

Jul 12, 2016 am 08:49 AM
js unix timestamp Timestamp

A summary of all PHP timestamp formats (getting time, timestamp), php

There are many kinds of functions in the PHP language, with different application methods and different functions. All the same. I hope it will be helpful for newbies to learn!

1. The PHP timestamp function obtains the unix timestamp of the specified date strtotime("2009-1-22"). The example is as follows:

echo strtotime(”2009-1-22″) Result: 1232553600

Description: Return the timestamp of 0:00:00 on January 22, 2009

2. The PHP timestamp function obtains the English text date and time. The example is as follows:

For comparison, use date to convert the current timestamp and the specified timestamp into system time

(1) Print the timestamp of tomorrow at this time strtotime(” 1 day”)

Current time: echo date(”Y-m-d H:i:s”,time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime(" 1 day")) Result: 2009-01-23 09:40:25

(2) Print the timestamp of yesterday at this time strtotime(”-1 day”)

Current time: echo date(”Y-m-d H:i:s”,time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime("-1 day")) Result: 2009-01-21 09:40:25

(3) Print the timestamp at this time next week strtotime(” 1 week”)

Current time: echo date("Y-m-d H:i:s",time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime(" 1 week")) Result: 2009-01-29 09:40:25

(4) Print the timestamp at this time last week strtotime(”-1 week”)

Current time: echo date(”Y-m-d H:i:s”,time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime("-1 week")) Result: 2009-01-15 09:40:25

(5) Print the timestamp of the specified day of the week strtotime("next Thursday")

Current time: echo date(”Y-m-d H:i:s”,time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime("next Thursday")) Result: 2009-01-29 00:00:00

(6) Print the timestamp of the specified day of the week strtotime("last Thursday")

Current time: echo date(”Y-m-d H:i:s”,time()) Result: 2009-01-22 09:40:25

Specify time: echo date("Y-m-d H:i:s",strtotime("last Thursday")) Result: 2009-01-15 00:00:00

(7) Print the timestamp of zero o'clock the previous day

$ystd = strtotime('-1 day'); // The timestamp of yesterday’s moment
$ystd = date("Y-m-d", $ystd); // Yesterday's date d

$ystd = strtotime($ystd." 00:00:00"); // The timestamp of 24:00 yesterday morning

As can be seen from the above PHP timestamp function example, strtotime can parse the date and time description of any English text into a Unix timestamp. We combine the mktime() or date() formatted date and time to obtain the specified timestamp to achieve what is needed. Date time.

The above summary of all PHP timestamp formats (getting time, timestamp) is all the content shared by the editor. I hope it can give you a reference, and I hope everyone will support Bangkejia.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1136656.htmlTechArticleA summary of all PHP timestamp formats (get time, timestamp), php There are many functions in the PHP language, Various application methods are different, and the functions implemented are also different. I hope it will be helpful for newbies to learn...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Recommended: Excellent JS open source face detection and recognition project Recommended: Excellent JS open source face detection and recognition project Apr 03, 2024 am 11:55 AM

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages ​​and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS Dec 17, 2023 pm 06:55 PM

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

Golang time processing: How to convert timestamp to string in Golang Golang time processing: How to convert timestamp to string in Golang Feb 24, 2024 pm 10:42 PM

Golang time conversion: How to convert timestamp to string In Golang, time operation is one of the very common operations. Sometimes we need to convert the timestamp into a string for easy display or storage. This article will introduce how to use Golang to convert timestamps to strings and provide specific code examples. 1. Conversion of timestamps and strings In Golang, timestamps are usually expressed in the form of integer numbers, which represent the number of seconds from January 1, 1970 to the current time. The string is

How to create a stock candlestick chart using PHP and JS How to create a stock candlestick chart using PHP and JS Dec 17, 2023 am 08:08 AM

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts Dec 18, 2023 pm 03:39 PM

With the rapid development of Internet finance, stock investment has become the choice of more and more people. In stock trading, candle charts are a commonly used technical analysis method. It can show the changing trend of stock prices and help investors make more accurate decisions. This article will introduce the development skills of PHP and JS, lead readers to understand how to draw stock candle charts, and provide specific code examples. 1. Understanding Stock Candle Charts Before introducing how to draw stock candle charts, we first need to understand what a candle chart is. Candlestick charts were developed by the Japanese

How to match timestamps using regular expressions in Go? How to match timestamps using regular expressions in Go? Jun 02, 2024 am 09:00 AM

In Go, you can use regular expressions to match timestamps: compile a regular expression string, such as the one used to match ISO8601 timestamps: ^\d{4}-\d{2}-\d{2}T \d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-][0-9]{2}:[0-9]{2})$ . Use the regexp.MatchString function to check if a string matches a regular expression.

The relationship between js and vue The relationship between js and vue Mar 11, 2024 pm 05:21 PM

The relationship between js and vue: 1. JS as the cornerstone of Web development; 2. The rise of Vue.js as a front-end framework; 3. The complementary relationship between JS and Vue; 4. The practical application of JS and Vue.

Best Practices for Timestamp Obtaining: A Powerful Tool in Golang Programming Best Practices for Timestamp Obtaining: A Powerful Tool in Golang Programming Dec 29, 2023 am 08:28 AM

Golang Programming Tool: Best Practices for Timestamp Obtaining Introduction: In software development, timestamp is a very common concept. It is a numeric value that identifies the occurrence of a specific event, usually representing the number of milliseconds or nanoseconds since some reference point in time. In Golang, processing timestamps is very simple and efficient. This article will introduce the best practices for obtaining timestamps in Golang and provide specific code examples. Text: Get the current timestamp In Golang, getting the current timestamp is very simple. we can

See all articles