的一个月,我需要一个通用的函数,它的日期,时间,UNIX时间戳表示,并返回,比如说,午夜表示的开始在当月的第一天。如何返回一个UNIX时间戳为特定的UNIX时间戳PHP
即我通过1352376093
现在代表(星期四,2012 12时01分33秒格林尼治标准时间11月08)和1351728000
返回代表(星期四,2012年11月1日00:00:00 GMT)
的一个月,我需要一个通用的函数,它的日期,时间,UNIX时间戳表示,并返回,比如说,午夜表示的开始在当月的第一天。如何返回一个UNIX时间戳为特定的UNIX时间戳PHP
即我通过1352376093
现在代表(星期四,2012 12时01分33秒格林尼治标准时间11月08)和1351728000
返回代表(星期四,2012年11月1日00:00:00 GMT)
该段应帮你解决问题。只要采取只月份和年份从现有的日期,并将其转换回时间戳。
<?php
$time = 1352376093;
$date = date('Y-m-01 00:00:00', $time);
$result = strtotime($date);
于是结束了这一功能:
$earliest_issue = db_result($result, 0);
$day_of_month_of_earliest_issue = date("d", $earliest_issue);
$hour_of_month_of_earliest_issue = date("h", $earliest_issue);
$minute_of_month_of_earliest_issue = date("i", $earliest_issue);
$seconds_in_month = date("s", $earliest_issue);
$seconds_in_day_of_month = (($day_of_month_of_earliest_issue*24*60*60)-86400);
$seconds_in_hour_of_month = (($hour_of_month_of_earliest_issue*60*60)-3600);
$seconds_in_minute_of_month = (($minute_of_month_of_earliest_issue*60));
$start_time_of_query = ($earliest_issue - $seconds_in_day_of_month - $seconds_in_hour_of_month - $seconds_in_minute_of_month - $seconds_in_month);
return $start_time_of_query;
其中$earliest_issue
是开始日期...
如果有人读这有我所希望的,那么请有助于一个更优雅的功能, 谢谢!