/**
- Examples of PHP timestamp synthesis application
- Date:2013/2/19
- link:http://bbs.it-home.org
- */
- $t = time ();
- $t 1 = mktime (0,0,0,date ("M", $t), date ("D", $t), date ("Y", $t));
- $t 2 = mktime (0,0,0,date ("M", $t), 1,date ("Y", $t));
- $t 3 = mktime (0,0,0,date ("M", $t) -1,1,date ("Y", $t));
- $t 4 = mktime (0,0,0,1,1,date ("Y", $t));
- $e 1 = mktime (23,59,59,date ("M", $t), date ("D", $t), date ("Y", $t));
- $e 2 = mktime (23,59,59,date ("M", $t), date ("T"), Date ("Y", $t));
- $e 3 = mktime (23,59,59,date ("M", $t) -1,date ("T", $t 3), date ("Y", $t));
- $e 4 = mktime (23,59,59,12,31,date ("Y", $t));
Test
- echo Date ("Current y-m-d h:i:s", $t). "$t
”;
- Echo Date ("Today's beginning y-m-d h:i:s", $t 1). "$t 1
”;
- Echo Date ("The beginning of this month y-m-d h:i:s", $t 2). "$t 2
”;
- echo Date ("Last month beginning y-m-d h:i:s", $t 3). "$t 3
”;
- Echo Date ("The beginning of this year y-m-d h:i:s", $t 4). "$t 4
”;
- Test
- Echo Date ("Today's End y-m-d h:i:s", $e 1). "$e 1
”;
- echo Date ("Y-m-d h:i:s" at the end of this month, $e 2). "$e 2
”;
- echo Date ("Last month end y-m-d h:i:s", $e 3). "$e 3
”;
- echo Date ("End of this year y-m-d h:i:s", $e 4). "$e 4
”;
- ?>
Copy CodeOutput: Current 2011-05-24 15:42:55 1306222975 today beginning 2011-05-24 00:00:00 1306166400 this month beginning 2011-05-01 00:00:00 1304179200 last month beginning 2011- 04-01 00:00:00 1301587200 This year start 2011-01-01 00:00:00 1293811200 today end 2011-05-24 23:59:59 1306252799 this month end 2011-05-31 23:59:59 1306857599 last month 2011-04-30 23:59:59 1304179199 end of this year 2011-12-31 23:59:59 1325347199 |