A black humor _php tutorial using Mktime to get timestamps in PHP

Source: Internet
Author: User
Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST) This is mktime syntax, at a glance should not be difficult to write a timestamp code!

The following code is the online most people give the time stamp reality, this one can only say that a look at the current date, but not a timestamp, do not have to explain it!
1 $now = Mktime (0,0,0,date ("M"), Date ("D"), Date ("Y"));
2 echo "Now is". Date ("y/m/d", $now);
Show Results:
Now is 2012/05/30
Obviously this is not the result I want.
So, according to the old thinking, I take it for granted to the following form:
1 $now = mktime (Date ("H"), Date ("M"), date ("s"), date ("M"), Date ("D"), Date ("Y"));
2 echo "Now is". Date ("Y/m/d h:i:s", $now);
Note the red part, usually if the month is in M, then the minute should be M. Or the former with M, the latter with M.
Show Results:
Warning:mktime () expects parameter 2 to being long, string given in D:\usr\webroot\testPHP\index.php on line 46
Now is 1970/01/01 08:jan:00
It seems that it is not advisable to be judgmental, and PHP's syntax is somewhat different from other languages.

Not suspense, or directly to everyone the right answer
1 $now = mktime (Date ("H"), Date ("I"), date ("s"), date ("M"), Date ("D"), Date ("Y"));
2 echo "Now is". Date ("Y/m/d h:i:s", $now);
haha ~ is "i" instead of what m or m, here is a sample of this example just want to let PHP beginners to take a few detours.
As for what m means, we can understand it by doing it by ourselves ... Hey!!!
Show Results:
Now was 2012/05/30 04:54:25

There are too many people on the network to copy the article, not many people to dig into this, so that PHP beginners like me at a loss. Copy copy before you do not have to do a lot of their own implementation in writing, to oneself is an improvement, the reader is also always responsible attitude.

Excerpt from the East Blog

http://www.bkjia.com/PHPjc/478177.html www.bkjia.com true http://www.bkjia.com/PHPjc/478177.html techarticle mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST) This is mktime syntax, at a glance should not be difficult to write a timestamp code! The following code is online most people give ...

  • 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.