- $now = Mktime (0,0,0,date ("M"), Date ("D"), Date ("Y"));
- echo "Now is". Date ("y/m/d", $now);
Copy CodeDisplaying results: Now was 2012/05/30 obviously this is not the result I want. Then, according to the old thinking, take for granted the following form of transformation:
- $now = mktime (Date ("H"), Date ("M"), date ("s"), date ("M"), Date ("D"), Date ("Y"));
- echo "Now is". Date ("Y/m/d h:i:s", $now);
Copy CodeNote 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. displaying results: Warning:mktime () expects parameter 2 to being long, string given in D:\usr\webroot\testPHP\index.php on line 1970/01/01 08:jan:00 The correct answer is this:
- $now = mktime (Date ("H"), Date ("I"), date ("s"), date ("M"), Date ("D"), Date ("Y"));
- echo "Now is". Date ("Y/m/d h:i:s", $now);
Copy Codehaha ~ 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, smart, you must understand. Displaying results: Now was 2012/05/30 04:54:25 >>> you may be interested in the article: PHP in Time (), date (), mktime () The difference between time () and mktime () usage in PHP php strtotime () and Mktime () Issue of y2k38 Vulnerability 2038 |