Time () is a number in PHP that indicates how many seconds have gone from 1970-01-01 to now, it's weird.
But it's easy to calculate,
To find out the day before is time () -60*60*24;
To find out when the previous year was time () *60*60*24*365
So
PHP datetime function Date ()
1, year-month-day
echo Date (' y-m-j ');
2007-02-6
echo Date (' y-n-j ');
07-2-6
Uppercase Y represents the year four digits, while lowercase y represents the two digits of the year;
Lowercase m represents the
PHP time and date functions in a detailed
PHP function of the diversification and functional similarity is really a big feature, the same application can be implemented with a variety of functions, which is probably a disadvantage of open source,
Add Date_default_timezone_set (PRC) to the top page of the page; /* Transfer time to Beijing time, php5 default to Greenwich Mean Time */date () A: "AM" or "PM" A: "AM" or "PM" D: A few days, two digits, if not enough to fill 0; from "01" to "D: Day
After php5.1.1, the date function adds the following constants.
The following constants are defined from PHP 5.1.1 to provide standard date Expression methods. They can be used for date format functions (such as date ()).
DATE_ATOM (string)Atomic
MySQL _ date function summary and mysql function Summary
If it is reprinted, please indicate the source of the blog: www.cnblogs.com/xinysu/. The copyright belongs to xiaoradish in the blog garden. Thank you for your support!
For MySQL date and
A-"AM" or "PM"A-"AM" or "PM"D-A few days, two digits, if less than two is the front 0; such as: "01" to "31"D-Days of the week, three English letters; such as: "Fri"F-month, full name in English; such as: "January"H-12 hours of the hour; such as: "01
Generally when you need to use the time, we will declare:Header (' Content-type:text/html;charset=utf-8 ');Date_default_timezone_set (' PRC '); The people ' s Republic of China
A-"AM" or "PM"
A-"AM" or "PM"
D-A few days, two digits, if less
Day of the D month, 2 digits with leading zeros 01 to 31The day of the D-week, the text says, 3 letters Mon to SunDay of the J month, without leading 1 to 31L (Lowercase letter of "L") Day of the week, full text format Sunday to SaturdayN ISO-8601
var mydate = new Date (); Mydate.getyear (); //Get Current year (2-bit) Mydate.getfullyear (); //Get the full year (4-bit, 1970-????) Mydate.getmonth (); //Get the current month (0-11, 0 for January) Mydate.getdate (); //Get
Date_default_timezone_get (): Gets the current time zone of PHP date_default_timezone_set (): Sets the current time zone for PHPDate ("Y-m-d h-i-s")time (): Returns the current timestamp (1970-1-1--to date) unit seconds
strtotime (): Converts the
Browser compatibility of the Date function new Date () in javascript, javascriptdate
Javascript in the same language has a language compatibility problem in different browsers. Essentially, different browsers support different language standards and
The date () function of PHP is described in detail
1, year-month-dayecho Date (' y-m-j ');2007-02-6echo Date (' y-n-j ');07-2-6Uppercase Y represents the year four digits, while lowercase y represents the two digits of the year;Lowercase m
Date function usage The code is as follows:Copy code Date ($ t ); The format is as follows:Format: year-month-day hour: minute: SecondRelated time parameters:A-"am" or "pm"A-"AM" or "PM"D-a few days, two digits. If there are less than two
If the date time is inconsistent, use date_default_timezone_set to set the time zone: The code is as follows:Copy code // Obtain the current timeEcho date ('Y-m-d H: I: S', time ());Echo " "; // Calculate the current timeEcho date ('Y-m-d H: I:
/** * Convert date to a specified format of string * months (M), Day (d), 12 hours (h), 24 hours (h), minutes (m), seconds (s), Weeks (E), quarter (q) can use 1-2 placeholders * year (y) can use 1-4 placeholders, milliseconds (s) only with A
All date and time APIs are within the DateTime module.1. Date output formatted datetime/= stringImport datetimenow = Datetime.datetime.now ()Now.strftime ('%y-%m-%d%h:%m:%s ')Output' 2015-04-07 19:11:21 'Strftime is an instance method of a DateTime
Add Date_default_timezone_set (PRC) to the top page of the page; /* Transfer time to Beijing time, php5 default to Greenwich Mean Time */date () A: "AM" or "PM" A: "AM" or "PM" D: A few days, two digits, if not enough to fill 0; from "01" to "D: Day
Date(PHP 4, PHP 5)date-format a local time/date description?String date (string $format [, int $timestamp ])Returns a string that is the result of an integer in a timestamp given format string. If no timestamp is given, the local current time is
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.