Home>Article>Backend Development> How to get the timestamp of the beginning and end of a specified month using php

How to get the timestamp of the beginning and end of a specified month using php

little bottle
little bottle forward
2019-04-23 10:31:44 4424browse

This article mainly talks about using php to obtain the timestamps at the beginning and end of a specified month. It has certain reference value. Interested friends can learn about it.

How to get the timestamp of the beginning and end of a specified month using php

Get the start timestamp and end timestamp of the specified month, just pass in the year and month (both formats 2018-01 and 2018-1 are acceptable), The code is as follows:

$data['sel_time'] = '2018-11'; $data['begin_time'] = strtotime($data['sel_time']); //指定月份的开始时间戳 $data['end_time'] = mktime(23,59,59,date('m',strtotime($data['sel_time']))+1,00); //指定月份月末时间戳 echo $data['begin_time']."
".$data['end_time'];

Result:

Related tutorials:PHP video tutorial

The above is the detailed content of How to get the timestamp of the beginning and end of a specified month using php. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete