How to convert 30 days to timestamp in php

藏色散人
Release: 2023-03-17 13:14:02
Original
1233 people have browsed it

php method to convert 30 days into timestamp: 1. Create a php sample file; 2. Pass "mktime(0,0,0,date('m'),1,date('Y '));mktime(23,59,59,date('m'),date('t'),date('Y'));" can be used to obtain the start and end timestamps of this month.

How to convert 30 days to timestamp in php

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

How to convert 30 days into timestamp in PHP?

First explain the format of the date() function:

date('Y-m-d',timestamp); //输出年-月-日
date('Y-m-d H:i:s',timestamp); //输出年-月-日 时:分:秒
Copy after login

php gets today’s date

date("Y-m-d",strtotime("today")); //strtotime('today')输出今天的开始时间戳
Copy after login

or

date("Y-m-d",time()); //time()输出当前的秒时间戳
Copy after login

php gets yesterday’s date

date("Y-m-d",strtotime("-1 day")); 或 date("Y-m-d",strtotime("yesterday"));
Copy after login

phpGet tomorrow's date

date("Y-m-d",strtotime("+1 day")); 或 date("Y-m-d",strtotime("tomorrow "));
Copy after login

phpGet the date 7 days later

date("Y-m-d",strtotime("+7 day"));
Copy after login

phpGet the date 30 days later

date("Y-m-d",strtotime("+30 day"));
Copy after login

phpGet the date one week later

date("Y-m-d",strtotime("+1 week"));
Copy after login

php Get the date one month later

date("Y-m-d",strtotime("+1 month"));
Copy after login

php Get the date one month ago

date("Y-m-d",strtotime("last month")); 或 date("Y-m-d",strtotime("-1 month"));
Copy after login

php Get the date one year later

date("Y-m-d",strtotime("+1 year"));
Copy after login

php Get the date one week, two days and four hours Time after five minutes and two seconds

date("Y-m-d H:i:s",strtotime("+1 week 2 days 4 hours 5 minute 2 seconds"));
Copy after login

php Gets the date of next Thursday

date("Y-m-d",strtotime("next Thursday"));
Copy after login

php Gets the date of last Monday

date("Y-m-d",strtotime("last Monday"));
Copy after login

php Gets the start and end timestamps of today

mktime(0,0,0,date('m'),date('d'),date('Y')); 
mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
Copy after login

php Gets the start and end timestamps of yesterday

mktime(0,0,0,date('m'),date('d')-1,date('Y'));
mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
Copy after login

php Gets the start and end timestamps of last week

mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
Copy after login

php Gets the start and end timestamps of this month

mktime(0,0,0,date('m'),1,date('Y'));
mktime(23,59,59,date('m'),date('t'),date('Y'));
Copy after login

Recommended study: " PHP video tutorial

The above is the detailed content of How to convert 30 days to timestamp in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template