How to get the current timestamp in php: 1. Use the time() function directly, with the syntax "time()"; 2. Use the strtotime() function, with the syntax "strtotime("now")".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php gets the current time Stamping method
1. Use time()
time() function returns the Unix epoch (January 1 1970 00:00:00 GMT) the current time in seconds.
Syntax: time();
Returns an integer containing the Unix timestamp of the current time.
Example:
<?php echo time(); ?>
Output:
1635851460
2. Use strtotime()
strtotime() function to Any string datetime description resolves to a Unix timestamp (number of seconds since January 1 1970 00:00:00 GMT).
语法:strtotime ( $time [, $now = time() ] )
time: required. Specifies a date/time string.
#now: Optional. Specifies the timestamp used to calculate the return value. If this parameter is omitted, the current time is used.
Example: Current timestamp
<?php header("Content-type:text/html;charset=utf-8"); echo strtotime("now"); ?>
Output:
1635851553
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What are the ways to get the current timestamp in php. For more information, please follow other related articles on the PHP Chinese website!

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

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

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

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

Dreamweaver Mac version
Visual web development tools
