Jump to content

PHP w/Mysql (Dates)


Ninjakreborn

Recommended Posts

<?php
	$date = date('Y-m-d');
	$strtime = strtotime('today +14 days'); 
	$strtime = date('Y-m-d', $strtime);
	if ($distributor != 1) {
		$select = "SELECT deal_data.headline AS headline FROM deal_data
		WHERE str_to_date(deal_data.end_date,'%Y/%m/%d') BETWEEN str_to_date('" . $date . "', '%Y/%m/%d') and str_to_date('" . $strtime . "', '%Y/%m/%d')";
	}else {
		$select = "SELECT deal_data.headline AS headline FROM deal_data
		WHERE str_to_date(deal_data.end_date,'%d.%m.%Y') BETWEEN '" . $date . "' and '" . $strtime . "'";
	}
?>

The dates are formatted in the database as Varchar (I don't do that anymore, this is an old project) and are formatted as: "09/12/2010".

 

Anything wrong with the above code that would make it not work and return queries?

Link to comment
https://forums.phpfreaks.com/topic/213164-php-wmysql-dates/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.