PHP time () date () Strtotime () Dates function summary

Source: Internet
Author: User

Summary of date functions-- One, return timestamp-if the overall value is beyond the computer capabilities, return NULL. 1. Time (); Returns the current Unix timestampExample: $a =time (); Var_dump ($a); Output: Int (1392192781)2.strtotime (); resolve other formats to Unix timestamps Example: $b = Strtotime ("Now"); Var_dump ($b); Output: Int (1392192781) /* Format example in parentheses: ("Ten September 2000") ("+1 Day")Tomorrow ("+1 days")Tomorrow ("+1 Week") ("+1 Week 2 days 4 hours 2 seconds") ("Next Thursday")Next Tuesday ("Last Monday") ("2011-5-19 14:07"); */3.mktime (time [, minute [, Seconds [, Month [, Day [, Year]]]]); Can go beyond the natural range, such as 27 months, exceeding the high plus; returns false if the overall value is outside the computer's ability range. Example: Var_dump (Mktime (12,0,0,12,30,2012)); Output: Int (1356868800)4.microtime (); a timestamp string that returns the Microsecond precision. second, return an array1.getdate (); timestamp (default today) returns an array. $today = getdate (); Var_dump ($today); /* Output array: Array (11) { ["Seconds"]=>int (32) ["Minutes"]=>int (27) ["Hours"]=>int (8) ["Mday"]=>int (12) ["Wday"]=>int (3) ["Mon"]=>int (2) ["Year"]=>int (2014) ["Yday"]=>int (42) ["Weekday"]=>string (9) "Wednesday" ["Month"]=>string (8) "February" [0]=>int (1392193652) } */ third, formatted outputDate (); Format string Date (string format [, int timestamp]) String format is commonly used: Y: Four-digit years m: Month 01-12 N: Month 1-12D: Day 01-31 J: Day 1-31 H: 24 o'clock H: Hour 12 I: Min 00-59 s: sec 00-59 W: Day of the week 0-6 A: a.m. AM or PM A: AM or PM. Example: Var_dump (Date ("Y-m-d h:i:s", 1391919385)); String (19) "2014-02-09 04:16:25" Iv. Modifying the default time zone1, repair php.ini configuration file: Date.timezone = etc/gmt+82, Date_default_timezone_set (); Sets the default time zone for all datetime functions in a script.such as: Date_default_timezone_set ("PRC"); China time zone.Another: Date_default_timezone_get (); Get Current time zone

So here's the question:

1. Ask for a time stamp of the morning?

2. What are the days of January 1 next year from today (early morning of the next day)?

PHP time () date () Strtotime () Dates function summary

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.