This article to introduce you to the use of PHP with Strtotime or mktime specified date data (this week, last week, this month, last month, this quarter) instance, I hope that the students will help you.Strtotime Definition and usageThe strtotime ()
Today's small series to introduce you to a PHP strtotime calculation on the one months of today's problem resolution, if you hit the calculation for one months today there is a problem not to enter the reference.
PHP, last one months
Strtotime has a
Strtotime Definitions and usage
The strtotime () function resolves the date-time description of any English text to a Unix timestamp.
Grammar
Strtotime (time,now) parameter descriptionTime to specify the string to parse.Now is the time stamp used
In php, the strtotime () function resolves the datetime description of any English text to a Unix timestamp, which is also frequently used, if you have any need, refer to using strtotime to convert Time strings of various formats into timestamps.
If the time format is absolute time, the now parameter does not work. If the time format is relative time, the relative time is provided by now, or if the now parameter is not provided, the current time is used. -1 is returned if the request
How does strtotime treat arrays? Yes. to submit a form, replace the time in date format with the timestamp. Previously, strtotime & nbsp; was used directly, but because the form needs to be clicked to add rows as needed, now all fields are converted
If the format of time is absolute, then the now parameter does not work. If the format of time is relative, its relative time is provided by now, or if it is not supplied with the current time. Returns-1 on failure.
Echo Strtotime ("Now"), "\
How does strtotime treat arrays? Yes. to submit a form, replace the time in date format with the timestamp. Previously, strtotime & nbsp; was used directly, but because the form needs to be clicked to add rows as needed, now all fields are converted
If the time format is absolute time, the now parameter does not work. If the time format is relative time, the relative time is provided by now, or if the now parameter is not provided, the current time is used. -1 is returned if the request fails.
The now parameter does not work if the time is in absolute times format. If time is in a relative time format, it is provided by now, or the current time is not available if the?? Returns-1 when failed.
Echo Strtotime ("Now"), "\ n";
Echo
Before the development project, encountered the use of Strtotime ("-1 months") will be a bug, mainly because the default PHP time is set in Greenwich time zone standard, there are two ways to solve this problem, one is to modify the default time
P use Strtotime to calculate the number of days between a given date two
This article mainly introduces PHP using Strtotime to calculate the number of days between two a given date method, the example analysis of PHP operation time skills, very
Time (): Returns the current UNIX timestamp;Date (): formats a local timestamp;Mktime (hour, minute, second, month, day, year): Gets a timestamp of the date;Strtotime (): Resolves the datetime description of any English text to a UNIX timestampecho
echo Date (' Y-m ', Strtotime ('-1 months '));echo "\ r \ n";echo Date (' Y-m ', Strtotime (' first day of the last month ');echo "\ r \ n";echo Date (' Y-m ', Strtotime ('-1 week '));650) this.width=650; "Src="
Strtotime (Date ("y-m-01 00:00:00")); Used to get the first day of the month time stamp
In the actual PHP strtotime application suddenly once encountered the conversion time is 8 hours slower than the actual time! I thought it was in
The same two lines of code,
"; Echo strtotime ($ts);? >
Running on a Linux server, the result is this:
2013-01-01 11:11:111357009871000
But when I run on this machine, the timestamp is the other one, what's going on?
The time zone on the
Use Strtotime to convert time strings in various formats to timestamps
Convert General time format
Convert Natural Time Description
Yesterday echo date (' y-m-d h:i:s ', Strtotime (' Yesterday ')). php_eol;//last week, echo date (' y-m-d
Strtotime at this time of the Unix timestamp, the need for a friend can be a simple reference, the middle also said the GETDATE function, then can be output seconds and minutes.
The code is as follows
Copy Code
PHP resolution for Strtotime ("-X Month") Bug
Strtotime ('-X month '); You may not get the expected results when it comes to month changes.
This is a bug in PHP:
https://bugs.php.net/bug.php?id=27793
?
For example: Current time: 2011-08-31 17:21:2
PHP operation time function strtotime () detailed
The "time before printing" format conversion topic, is:
echo Date ("Y-m-d h:i:s", Strtotime ("1 day"));
"Print the first day of the last one months":
$a =mktime (0,0,0,date ("M") -1,1,date
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.