mktime(hour, minute, second, month, day, year, is_dst) This is the syntax description of mktime. It is clear at a glance and it should not be difficult to write a timestamp code!
The following code is the timestamp reality given by most people on the Internet. You can tell at a glance that this can only be said to obtain the current date, not a timestamp. No need to explain it further!
1 $now = mktime(0,0,0,date("m"),date("d"),date("Y"));
2 echo "now is ".date("Y/m/d", $now);
Display results:
now is 2012/05/30
Obviously this is not the result I want.
So, according to the old thinking, I took it for granted and transformed it into 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);
Pay attention to the red part. Usually if the month is m, then the minute should be M. Or use M for the former and m for the latter.
Display results:
Warning: mktime() expects parameter 2 to be long, string given in D:usrwebroottestPHPindex.php on line 46
now is 1970/01/01 08:Jan:00
It seems that subjective assumptions are not advisable. PHP's syntax is still somewhat different from other languages.
Without further ado, I’ll give you the correct answer directly
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~ It’s “i” instead of m or M. I give you this example just to make it easier for beginners of PHP to avoid some detours.
As for what M means, you will understand after you try it yourself... Hehe! ! !
Display results:
now is 2012/05/30 04:54:25
There are too many people copying each other's articles on the Internet, and not many people go into this, leaving PHP beginners like me at a loss. Before copying and copying, should you be more hands-on and implement it yourself before writing it? It will improve yourself and always be responsible for the readers.
Excerpted from Xiangdong Blog