Home  >  Article  >  Backend Development  >  How to convert timestamp to month in php

How to convert timestamp to month in php

青灯夜游
青灯夜游Original
2021-09-28 19:26:262922browse

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).

How to convert timestamp to month in php

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:

How to convert timestamp to month in php

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!

Statement:
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