mysql查询当天,查询本周,查询本月的数据(字段是时间戳)
$start = date('Y-m-d 00:00:00');
$end = date('Y-m-d H:i:s');
SELECT * FROM `table_name` WHERE `time` >= unix_timestamp( '$start' ) AND `time` <= unix_timestamp( '$end' )
SELECT yearweek( '2011-04-17 15:38:22',1 )
SELECT yearweek( '2011-04-17 15:38:22' )
SELECT dayofweek( '2011-04-17 15:38:22' )
SELECT dayofweek( '2011-04-18 15:38:22' )
SELECT weekday( '2011-04-17 15:38:22' )
SELECT weekday( '2011-04-18 15:38:22' )
SELECT * FROM `table_name` WHERE YEARWEEK( FROM_UNIXTIME( `time`, '%Y-%m-%d %H:%i:%s' ) ,1) = YEARWEEK( now( ),1 )
$start = date('Y-m-01 00:00:00');
$end = date('Y-m-d H:i:s');
SELECT * FROM `table_name` WHERE `time` >= unix_timestamp('”.$start.”') AND `time` <= unix_timestamp('$end')
$start = date('Y-01-01 00:00:00');
$end = date('Y-m-d H:i:s');
SELECT * FROM `table_name` WHERE `time` >= unix_timestamp( '$start' ) AND `time` <= unix_timestamp( '$end' )
php 获取今日、昨日、上周、本月的起始时间戳和结束时间
//
$beginToday = mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday = mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
echo $beginToday.'---'.$endToday;
echo '
';
$beginYesterday = mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday = mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
echo $beginYesterday.'---'.$endYesterday;
echo '
';
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
echo $beginLastweek.'---'.$endLastweek;
echo '
';
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'));
echo $beginThismonth.'---'.$endThismonth;
echo '
';
echo(date("M-d-Y",mktime(0,0,0,12,36,2001)));