strtotime 稍有不同

1. php : int time(void)  不需要参数,传入任何值都返回当前时间戳

2. php : int mktime(int hour, int minute, int second, int month, int day int year)

            参数可以从右向左省略,任何省略的参数会被设置成本地日期和时间的当前值

            year,可以是两位或四位数字,0-69对应于2000-2069,70-100对应于1970-2000。

            非法参数返回false

3. php : string date(string format, [int timestamp])

            日期格式化,太多查文档

            常用 : "Y-m-d"  "2013-04-25"

                       "y-m-d"  "13-04-25"

                       "Y-n-j"   "2013-4-25"

                       "M j Y"   "Apr 25 2013"

            应该很有用的:

                        "t"  给定月份应有的天数

                        "L"  是否闰年,1为闰年,0非闰年

4. php : int strtotime(string time) 返回时间戳

<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
?> 

         自己用,一般还是咱的习惯:

             strtotime("2013-4-25")

             当strtotime认为参数不合法时:

echo date("Y-m-d H:m:s", strtotime('2012'));
输出:2013-04-25 20:04:00      strtotime('2012')返回1366920720
echo date("Y-m-d H:m:s", strtotime());
输出:1970-01-01 00:01:00      strtotime()返回false

  

原文地址:https://www.cnblogs.com/frostbelt/p/3042081.html