Home >Backend Development >PHP Problem >How to get the specified timestamp in php
In PHP, you can use the date() function to get the number of the specified timestamp. This function can format the timestamp into a more readable date and time. When the parameter is set to "d" or "j", you can get the specified timestamp number, the syntax is "date("d", timestamp)" or "date("j", timestamp)".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
PHP date() function can format the timestamp into a more readable date and time.
A timestamp is a character sequence that represents the date/time when a certain event occurred.
Syntax
string date ( string $format [, int $timestamp ] )
format Required. Specifies the format of the timestamp.
timestamp Optional. Specify timestamp. The default is the current date and time.
The first required parameter format of the date() function specifies how to format the date/time.
Here are some available characters:
d represents the day of the month, a 2-digit number with leading zeros
j represents the day of the month Days, no leading zero
The example is as follows:
<?php echo date("d") . "<br>"; echo date("j") . "<br>"; echo date("Y-m-d"); ?>
Output result:
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of How to get the specified timestamp in php. For more information, please follow other related articles on the PHP Chinese website!