Date_default_timezone_set (' Asia/shanghai '); Setting the time zone
One, format time function date, return string
@params
String Date (String param1,intparam1,inttime)
1.date functions (vs. printf, sprintf functions)
Date (' Time format ' [, ' timestamp ']);
Date (' y-m-01 ', Time ())//Get the first day of the month eg:2015-07-30
Time format
Year: L, y, y, O
Date (' L ', Time ())//Determines whether a year is a leap, if it is 1, otherwise 0
Date (' Y ', Time ())//2015
Date (' Y ', Time ())//15
Months: F, M, M, N, t
Date (' F ', Time ())//month, full text format, such as January or March
Date (' m ', Time ())//The month represented by the number, with a leading 1 to 12
Date (' M ', Time ())//three-letter abbreviation for month Jan to Dec
Date (' n ', Time ())//The month represented by the number, without leading 1 to 12
Date (' t ', Time ())//t the number of days that the given month should be 28 to date (' Y years m months have t days ', Time ()) string ' July 2015 has 31 days ' (length=18)
Day: D, J
Date (' d ') judging today is the day of the month, with a leading zero of two digits 01 to 31
Date (' J ') judging today is the day of the month, with a leading zero of two digits 1 to 31
Day 0 to 366 in the date (' Z ') year
Week: D, N, W, Z, l
Date (' D ') Day of the Week, text representation, 3 letters Mon to Sun
Date (' L ') day of the week, full text format Sunday to Saturday
Date (' N ') ISO-8601 format number represents the day ordinal of the week (PHP 5.1.0 new Plus) 1 (for Monday) to 7 (represents Sunday)
Date (' W ') Day of the week, number representing 0 (representing Sunday) to 6 (for Saturday)
Time
Date (' a ') lowercase morning and afternoon values am or PM
Date (' A ') uppercase morning and afternoon values am or PM
Hours
Date (' G ') hour, 12-hour format, no leading 1 to 12
Date (' G ') hour, 24-hour format, no leading 00 to 23
Date (' H ') hour, 12-hour format, with leading 1 to 12
Date (' H ') hour, 24-hour format, with leading 000 to 23
Minutes
Date (' I ') has a leading zero in minutes of 00 to 59
Date (' s ') has a leading zero number of seconds 00 to 59
second, time stamp
1.strtotime Parse the datetime description of any English text into a Unix timestamp
Format: int strtotime (string time[,inttime[,intnow])
The first parameter of Strtotime can be our common English time format, such as "2008-8-20" or "Ten September 2000" and so on. It can also be a time description based on the parameter now, such as "+1 Day" and so on.
One, gets the UNIX timestamp for the specified date
Strtotime ("2009-1-22") examples are as follows:
1.echo strtotime ("2009-1-22")
Results: 1232553600
Description: Return January 22, 2009 0:0 0 seconds timestamp
Second, get the English text date time
1. Get the relevant timestamp for a few days ago or a few days + or-' Day ' or ' Day '
Strtotime ("+10 days")
2. Get a few weeks ago or a few weeks after the time + or-' Week ' or ' weeks '
Strtotime ("+10 Week")
3. Get a time stamp for a specified number of days and hours of the week
Strtotime ("+1 Week 2 days 4 hours 2 seconds");
4. Get timestamp for last Monday or next Thursday
Strtotime ("Last Monday")
Strtotime ("next Thursday")
5 getting timestamps a few years ago or years later
Strtotime ("+3 Years")
6. Get the first day of next month
Date (' Y-m-1 ', Strtotime (' +1 month '))
7. Get the last day of the month
Idea: The first day of next month, minus one day
Tmp=date (' Y−m−1′,strtotime (' +1month′)); Vardump (Date (' Y−m−d′,strtotime ') (Tmp=date (' y−m−1′,strtotime '); Vardump (Date (' Y−m−d′,strtotime (tmp. '-1 day '));
This article introduces PHP time processing related knowledge, more relevant content please focus on PHP Chinese web.
First off recommendation:
PHP Edit user Information
PHP Delete User
Learning notes for MySQL