Home > Article > Backend Development > How to convert timestamp to month in php
The date() function can be used in PHP to convert the timestamp into a month. This function can format the timestamp into a readable date string; the syntax format is "date(format, timestamp); ", the parameter format can be F (complete text representation of the month), m (numeric representation) and M (short text representation).
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In PHP, you can use date () function to convert timestamp to month.
date() function formats the local date and time and returns the formatted date string.
Syntax:
date(format,timestamp);
The parameter format can be set to "F", "m", "M"
F - month Complete text representation (January[January] to December[December])
m - Numeric representation of the month (from 01 to 12)
M - A short text representation of the month (in three letters)
Example:
<?php header("Content-type:text/html;charset=utf-8"); $week = date("m","1632780000"); echo "月份为:".$week; $week = date("F","1632780000"); echo "<br>月份为:".$week; $week = date("M","1632780000"); echo "<br>月份为:".$week; ?>
Output:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to convert timestamp to month in php. For more information, please follow other related articles on the PHP Chinese website!