Code: Select all
$result = mysql_query("SELECT * FROM tbl_comments WHERE comments_date <= '$datetodaydate' AND comments_date <= '$dateyesterdaydate' ORDER BY comments_date DESC, comments_time DESC");Code: Select all
$datetodaydate // This will display current date DD-MM-YYYY
$dateyesterdaydate // Yesterday's DD-MM-YYYY
$datedaybefore // Day before yesterday's DD-MM-YYYYJust FYI, here's my date code:
Code: Select all
// ##### Date and Timezone Formatting ##### Start ->
$currenttime=gmt2aest(strftime("%Y-%m-%d %H:%M:%S"));
$tmp0=explode(" ",$currenttime);
$currdate=$tmp0[0];
$currtime=$tmp0[1];
$datetoday=gmt2aest(strftime('0 days'));
$tmp1=explode(" ",$datetoday);
$datetodaydate=$tmp1[0];
$datetodaytime=$tmp1[1];
$dateyesterday=gmt2aest(strftime('-1 days'));
$tmp2=explode(" ",$dateyesterday);
$dateyesterdaydate=$tmp2[0];
$dateyesterdaytime=$tmp2[1];
$datedaybefore=gmt2aest(strftime('-2 days'));
$tmp3=explode(" ",$datedaybefore);
$datedaybeforedate=$tmp3[0];
$datedaybeforetime=$tmp3[1];
// Daylight Savings function
function gmt2aest ($time){
date_default_timezone_set('GMT');
$date = new DateTime($time);
$aest_time= new DateTimeZone('Australia/Hobart');
$date->setTimezone($aest_time);
$newtime = $date->format("d-m-Y H:i:s");
return $newtime;
}
// Daylight Savings function
function aest2gmt ($time){
date_default_timezone_set('Australia/Hobart');
$date = new DateTime($time);
$gmt_time=new DateTimeZone('GMT');
$date->setTimezone($gmt_time);
$newtime = $date->format("d-m-Y H:i:s");
date_default_timezone_set('GMT');
return $newtime;
}
// ##### Date and Timezone Formatting ##### End <-