Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the mktime () function in php

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to use the mktime () function in php". The editor shows you the operation process through an actual case. The operation method is simple and fast, and it is practical. I hope this article "how to use the mktime () function in php" can help you solve the problem.

1. Description

Just send the hours, minutes, seconds, month, date, and year that mktime () wants to represent in order.

Mktime () returns the total number of seconds of that date since January 1, 1970.

two。 Grammar

Mktime (hour,minute,second,month,day,year,is_dst)

3. Parameters.

Hour is optional. Set hours.

Minute is optional. Minutes are required.

Second is optional. A rule of seconds.

Month is optional. A month that is specified to be expressed in numbers.

Day is optional. On a regular day.

Year is optional. The prescribed year. On some systems, the legal value is between 1901 and 2038. However, this restriction no longer exists in PHP 5.

Is_dst is optional. If the time is during daylight saving time (DST), it is set to 1, otherwise it is set to 0, and if unknown, it is set to-1. (since PHP 5.1.0, this parameter has been deprecated. You should use the new time zone processing feature instead. )

4. Return value

Returns an integer Unix timestamp, or FALSE if there is an error.

5. Example

/ / get today's start and end timestamps $start = mktime, date ('d'), date ('Y')); $end = mktime (0pje 0penny date ('m'), date ('d') + 1 moment date ('Y'))-1 beginYesterday stamp / get yesterday's start and end timestamps $beginYesterday = mktime (0pm 0last date ('m'), date ('d')-1 date ('Y')) $endYesterday = mktime, date ('d'), date ('Y')-1 date / get last week's start and end timestamps $beginLastweek = mktime, date ('d')-date ('w') + 1-7 endLastweek date ('Y'); $endLastweek = mktime (23line 59), date ('d')-date ('w') + 7-7 ~ date ('Y') / / get the start and end timestamps of the month $beginThismonth=mktime (0pj0pj0date ('m'), 1dint date ('Y')); $endThismonth=mktime (23force59d0date ('m'), date ('t'), date ('Y'))

In php, in addition to the contents of the array, it can be said that functions are universal in programming. For our use of time, there are also some functions that can play a role in php. What this article brings is mktime (), which can calculate the total number of seconds from a set time to a fixed time.

This is the end of the introduction to "how to use the mktime () function in php". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 295

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report