PHP convert date to timestamp
April 21st, 2009Instead of finding a way to manipulate 2 date pickers and find the range of dates and use each date.
why not convert each date produced by the date picker into unix timestamp and find the range
<?
//begindate/enddate has a format of “m d Y”
$splitbegindate = explode(‘ ‘, $begindate);
$splitenddate = explode(‘ ‘, $enddate);
$timestamp = mktime(’00′, ’00′, ’00′, $splitbegindate[0], $splitbegindate[1], $splitbegindate[2]);
$timestampend = mktime(’23′, ’59′, ’59′, $splitenddate[0], $splitenddate[1], $splitenddate[2]);// and then do the query
$query = “Select count(*),username, SUM(time_duration),… from $table where timestamp BETWEEN $timestamp AND $timestampend group by …. “;?>
much easier right?
